From a9cd71a82ac041b766991b1887f6f938da4e94a4 Mon Sep 17 00:00:00 2001 From: adeyblue Date: Wed, 7 Aug 2024 01:43:48 +0100 Subject: [PATCH] Allow long ar and ld command lines in standalone windows builds --- src/compiler/fbc.bas | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/compiler/fbc.bas b/src/compiler/fbc.bas index c6824b220..a4ffbcfa5 100644 --- a/src/compiler/fbc.bas +++ b/src/compiler/fbc.bas @@ -1381,26 +1381,27 @@ private function hLinkFiles( ) as integer exit function end if #elseif defined( __FB_WIN32__ ) + dim forcefile As Long + dim targetprefixlen As ULong #ifdef ENABLE_STANDALONE '' "cross"-compiling? djgpp cross tools and emscripten '' build tools can't seem to handle the long command line '' created when linking ./tests/fbc-tests select case fbGetOption( FB_COMPOPT_TARGET ) case FB_COMPTARGET_DOS, FB_COMPTARGET_JS - if( hPutLdArgsIntoFile( ldcline ) = FALSE ) then - exit function - end if + forcefile = 1 end select #else - dim toolnamelen as integer = len( "ld.exe " ) + _ - iif( len( fbc.targetprefix ) > len( fbc.buildprefix ), len( fbc.targetprefix ), len( fbc.buildprefix ) ) - if( (fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS) or _ - (len( ldcline ) > (2047 - toolnamelen)) ) then - if( hPutLdArgsIntoFile( ldcline ) = FALSE ) then - exit function - end if - end if + targetprefixlen = len( fbc.targetprefix ) #endif + dim toolnamelen as integer = len( "ld.exe " ) + _ + iif( targetprefixlen > len( fbc.buildprefix ), targetprefixlen, len( fbc.buildprefix ) ) + if( forcefile OrElse (fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS) or _ + (len( ldcline ) > (2047 - toolnamelen)) ) then + if( hPutLdArgsIntoFile( ldcline ) = FALSE ) then + exit function + end if + end if #endif '' invoke ld @@ -4162,6 +4163,22 @@ private function hArchiveFiles( ) as integer ar = FBCTOOL_EMAR end if +'' See comment in hLinkFiles about command line lengths +#if defined( __FB_WIN32__ ) or defined( __FB_DOS__ ) + dim targetprefixlen as ulong + #ifndef ENABLE_STANDALONE + targetprefixlen = len( fbc.targetprefix ) + #endif + dim toolnamelen as integer = len( fbctoolTB( ar ).name + ".exe" ) + _ + iif( targetprefixlen > len( fbc.buildprefix ), targetprefixlen, len( fbc.buildprefix ) ) + if( (fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS) or _ + (len( ln ) > (2047 - toolnamelen)) ) then + if( hPutLdArgsIntoFile( ln ) = FALSE ) then + exit function + end if + end if +#endif + '' invoke ar function = fbcRunBin( "archiving", ar, ln ) end function