13 #include once "file.bi"
15 #if defined( ENABLE_STANDALONE )
and defined(
__FB_WIN32__ )
88 outname as zstring * FB_MAXPATHLEN+1
89 mainname as zstring * FB_MAXPATHLEN+1
91 mapfile as zstring * FB_MAXPATHLEN+1
94 #ifndef ENABLE_STANDALONE
95 target as zstring * FB_MAXNAMELEN+1
104 prefix as zstring * FB_MAXPATHLEN+1
105 binpath as zstring * FB_MAXPATHLEN+1
106 incpath as zstring * FB_MAXPATHLEN+1
107 libpath as zstring * FB_MAXPATHLEN+1
127 "as",
"ar",
"ld",
"gcc",
"llc",
"dlltool",
"GoRC",
"windres",
"cxbe" _
132 byval tool
as integer, _
133 byref path
as string, _
134 byref relying_on_system
as integer =
FALSE _
139 byval action
as zstring ptr, _
140 byval tool
as integer, _
145 if(
kill( f ) <> 0 )
then
152 const FBC_INITFILES = 64
157 #ifndef ENABLE_STANDALONE
186 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_STATICLIB )
then
196 case FB_OUTTYPE_EXECUTABLE
198 case FB_COMPTARGET_DOS, FB_COMPTARGET_CYGWIN, _
199 FB_COMPTARGET_WIN32, FB_COMPTARGET_XBOX
204 case FB_OUTTYPE_DYNAMICLIB
206 case FB_COMPTARGET_CYGWIN, FB_COMPTARGET_WIN32
208 case FB_COMPTARGET_LINUX, FB_COMPTARGET_DARWIN, _
209 FB_COMPTARGET_FREEBSD, FB_COMPTARGET_OPENBSD, _
217 sub fbcEnd(
byval errnum
as integer )
218 if( errnum = 0 )
then
244 function fbcAddObj(
byref file
as string )
as string ptr
272 #ifndef ENABLE_STANDALONE
281 if( fbCpuTypeIs64bit( ) )
then
287 path +=
" -print-file-name=" + *file
289 dim as integer ff =
freefile( )
290 if(
open pipe( path,
for input,
as ff ) <> 0 )
then
314 if(
len( path ) > 0 )
then
321 byval tool
as integer, _
322 byref path
as string, _
323 byref relying_on_system
as integer _
326 static as integer lasttool = -1, last_relying_on_system
327 static as string lastpath
330 if( lasttool = tool )
then
332 relying_on_system = last_relying_on_system
336 relying_on_system =
FALSE
339 path =
environ(
ucase(
toolnames(tool) ) )
340 if(
len( path ) = 0 )
then
344 #ifndef ENABLE_STANDALONE
348 relying_on_system = TRUE
355 last_relying_on_system = relying_on_system
360 byval action
as zstring ptr, _
361 byval tool
as integer, _
365 dim as integer result =
any, relying_on_system =
any
371 print *action +
": ", path +
" " +
ln
377 #if defined(
__FB_UNIX__ )
or defined( ENABLE_STANDALONE )
378 result =
exec( path,
ln )
381 if( relying_on_system =
FALSE )
then
382 result =
exec( path,
ln )
384 result =
shell( path +
" " +
ln )
388 if( result = 0 )
then
390 elseif( result < 0 )
then
391 errReportEx( FB_ERRMSG_EXEMISSING, path, -1, FB_ERRMSGOPT_ADDCOLON
or FB_ERRMSGOPT_ADDQUOTES )
397 print *action +
" failed: '" + path +
"' terminated with exit code " +
str( result )
402 #if defined(
__FB_WIN32__ )
or defined(
__FB_DOS__ )
404 dim as string argsfile
405 dim as integer f =
any
410 if(
open( argsfile,
for output,
as #f ) )
then
439 print "ld options in '" & argsfile &
"': ", ldcline
442 ldcline =
"@" + argsfile
447 function clearDefList(
byref deffile
as string)
as integer
448 dim as integer fi =
freefile()
449 if (
open(deffile,
for input,
as #fi))
then
453 dim as string cleaned =
hStripExt(deffile) +
".clean.def"
454 dim as integer fo =
freefile()
455 if (
open(cleaned,
for output,
as #fo))
then
461 while (
eof(fi) =
FALSE)
464 if (
right(
ln, 4) =
"DATA")
then
465 ln =
left(
ln,
len(
ln) - 4)
475 return (
name(cleaned, deffile) = 0)
480 if(
open( deffile,
for output,
as #f ) )
then
492 byref dllname
as string, _
493 byref deffile
as string _
506 if(
filelen( deffile ) = 0 )
then
513 ln +=
"--def """ + deffile +
""""
529 function hFindLib(
byval file
as zstring ptr )
as string
531 if(
len( found ) > 0 )
then
532 function =
" """ + found +
""""
539 dim as string ldcline, dllname, deffile
546 case FB_COMPTARGET_WIN32
547 if( fbCpuTypeIs64bit( ) )
then
548 ldcline +=
"-m i386pep "
550 ldcline +=
"-m i386pe "
552 case FB_COMPTARGET_LINUX
553 if( fbCpuTypeIs64bit( ) )
then
554 ldcline +=
"-m elf_x86_64 "
556 ldcline +=
"-m elf_i386 "
561 ldcline +=
"-o " + QUOTE +
fbc.
outname + QUOTE
563 select case as const fbGetOption( FB_COMPOPT_TARGET )
564 case FB_COMPTARGET_CYGWIN, FB_COMPTARGET_WIN32
577 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB )
then
582 ldcline +=
" --dll --enable-stdcall-fixup"
585 ldcline +=
" -e _DllMainCRTStartup@12"
588 case FB_COMPTARGET_LINUX, FB_COMPTARGET_DARWIN, _
589 FB_COMPTARGET_FREEBSD, FB_COMPTARGET_OPENBSD, _
592 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB )
then
597 if(
left( dllname, 3 ) =
"lib" )
then
598 dllname =
right( dllname,
len( dllname ) - 3 )
601 select case as const fbGetOption( FB_COMPOPT_TARGET )
602 case FB_COMPTARGET_FREEBSD
603 ldcline +=
" -dynamic-linker /libexec/ld-elf.so.1"
604 case FB_COMPTARGET_LINUX
605 if( fbCpuTypeIs64bit( ) )
then
606 ldcline +=
" -dynamic-linker /lib64/ld-linux-x86-64.so.2"
608 ldcline +=
" -dynamic-linker /lib/ld-linux.so.2"
610 case FB_COMPTARGET_NETBSD
611 ldcline +=
" -dynamic-linker /usr/libexec/ld.elf_so"
612 case FB_COMPTARGET_OPENBSD
613 ldcline +=
" -dynamic-linker /usr/libexec/ld.so"
618 if( (
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB)
or _
620 ldcline +=
" --export-dynamic"
623 case FB_COMPTARGET_XBOX
624 ldcline +=
" -nostdlib --file-alignment 0x20 --section-alignment 0x20 -shared"
628 if (
fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS)
then
633 ldcline +=
" -T """ +
fbc.
libpath + (FB_HOST_PATHDIV +
"i386go32.x""")
636 ldcline +=
" """ +
fbc.
libpath + (FB_HOST_PATHDIV +
"fbextra.x""")
639 select case as const fbGetOption( FB_COMPOPT_TARGET )
640 case FB_COMPTARGET_CYGWIN, FB_COMPTARGET_WIN32
642 dim as integer stacksize =
fbGetOption(FB_COMPOPT_STACKSIZE)
643 ldcline +=
" --stack " +
str(stacksize) +
"," +
str(stacksize)
645 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB )
then
655 ldcline +=
" --output-def """ + deffile +
""""
658 case FB_COMPTARGET_XBOX
660 ldcline +=
" -e _WinMainCRTStartup"
665 ldcline +=
" -Bstatic"
682 ldcline +=
" -L """ + i->s +
""""
688 select case as const fbGetOption( FB_COMPOPT_TARGET )
689 case FB_COMPTARGET_CYGWIN
690 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB )
then
701 case FB_COMPTARGET_WIN32
702 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB )
then
714 case FB_COMPTARGET_DOS
721 case FB_COMPTARGET_LINUX, FB_COMPTARGET_DARWIN, _
722 FB_COMPTARGET_FREEBSD, FB_COMPTARGET_OPENBSD, _
725 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_EXECUTABLE)
then
727 select case as const fbGetOption( FB_COMPOPT_TARGET )
728 case FB_COMPTARGET_OPENBSD, FB_COMPTARGET_NETBSD
734 select case as const fbGetOption( FB_COMPOPT_TARGET )
735 case FB_COMPTARGET_OPENBSD, FB_COMPTARGET_NETBSD
744 if (
fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_OPENBSD)
then
750 case FB_COMPTARGET_XBOX
757 ldcline +=
" """ +
fbc.
libpath + (FB_HOST_PATHDIV +
"fbrt0.o""")
763 ldcline +=
" """ + *
objfile +
""""
777 ldcline +=
" """ + *libfile +
""""
786 dim as integer checkdllname = (
fbGetOption(FB_COMPOPT_OUTTYPE) = FB_OUTTYPE_DYNAMICLIB)
791 if ((checkdllname =
FALSE)
orelse (i->s <> dllname))
then
792 ldcline +=
" -l" + i->s
802 select case as const fbGetOption( FB_COMPOPT_TARGET )
803 case FB_COMPTARGET_LINUX, FB_COMPTARGET_DARWIN, _
804 FB_COMPTARGET_FREEBSD, FB_COMPTARGET_OPENBSD, _
807 if (
fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_OPENBSD)
then
811 case FB_COMPTARGET_WIN32
852 #elseif defined(
__FB_WIN32__ )
853 #ifdef ENABLE_STANDALONE
854 if(
fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS )
then
860 if( (
fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS)
or _
861 (
len( ldcline ) > (2047 -
len(
"ld.exe " ) -
len(
fbc.
targetprefix ))) )
then
874 select case as const fbGetOption( FB_COMPOPT_TARGET )
875 case FB_COMPTARGET_DOS
877 dim as integer f =
freefile()
879 if (
open(
fbc.
outname,
for binary,
access read write,
as #f) <> 0)
then
883 put #f, 533,
clng(
fbGetOption( FB_COMPOPT_STACKSIZE ) )
887 case FB_COMPTARGET_CYGWIN, FB_COMPTARGET_WIN32
888 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB )
then
895 case FB_COMPTARGET_XBOX
897 dim as string cxbepath, cxbecline
898 dim as integer res =
any
905 cxbecline =
"-TITLE:" + QUOTE +
fbc.
xbe_title + (QUOTE +
" ")
915 cxbecline +=
" " + QUOTE +
fbc.
outname + QUOTE
924 print "cxbe: ", cxbecline
930 res =
shell(cxbepath +
" " + cxbecline)
933 print "cxbe failed: exit code " & res
949 dim as integer lang =
any
951 #macro hReportErr( num )
965 hReportErr( FB_WARNINGMSG_MIXINGMTMODES )
975 if(
lang = FB_LANG_INVALID )
then
980 hReportErr( FB_WARNINGMSG_MIXINGLANGMODES )
994 dim as string ptr s =
any
995 dim as TSTRSETITEM
ptr i =
any
1009 if( i->userdata =
FALSE )
then
1026 errReportEx( FB_ERRMSG_INVALIDCMDOPTION, QUOTE + arg + QUOTE, -1 )
1041 byval is_rc
as integer _
1044 dim as integer o_option_not_used_yet = (
len(
fbc.
objfile ) = 0)
1047 if( o_option_not_used_yet )
then
1071 if( o_option_not_used_yet )
then
1078 sub hAddBas(
byref basfile
as string )
1082 #ifndef ENABLE_STANDALONE
1088 byref os
as string, _
1089 byref arch
as string _
1092 dim as integer i =
any, j =
any
1094 i =
instr( 1, os,
"-" )
1096 arch =
left( os, i - 1 )
1098 j =
instr( i + 1, os,
"-" )
1103 os =
right( os,
len( os ) - i )
1110 if(
len( os ) = 0 )
then
1114 #ifdef ENABLE_STANDALONE
1115 #macro MAYBE( s, comptarget )
1121 #macro MAYBE( s, comptarget )
1125 if(
left( os,
len( s ) ) = s )
then
1131 select case as const( os[0] )
1133 MAYBE(
"cygwin", FB_COMPTARGET_CYGWIN )
1136 MAYBE(
"darwin", FB_COMPTARGET_DARWIN )
1137 #ifndef ENABLE_STANDALONE
1138 MAYBE(
"djgpp", FB_COMPTARGET_DOS )
1140 MAYBE(
"dos", FB_COMPTARGET_DOS )
1143 MAYBE(
"freebsd", FB_COMPTARGET_FREEBSD )
1146 MAYBE(
"linux", FB_COMPTARGET_LINUX )
1148 #ifndef ENABLE_STANDALONE
1150 MAYBE(
"mingw", FB_COMPTARGET_WIN32 )
1151 MAYBE(
"msdos", FB_COMPTARGET_DOS )
1155 MAYBE(
"netbsd", FB_COMPTARGET_NETBSD )
1158 MAYBE(
"openbsd", FB_COMPTARGET_OPENBSD )
1165 MAYBE(
"win32", FB_COMPTARGET_WIN32 )
1166 #ifndef ENABLE_STANDALONE
1167 MAYBE(
"windows", FB_COMPTARGET_WIN32 )
1171 MAYBE(
"xbox", FB_COMPTARGET_XBOX )
1297 select case as const (
optid)
1323 fbSetOption( FB_COMPOPT_OUTTYPE, FB_OUTTYPE_OBJECT )
1333 fbSetOption( FB_COMPOPT_OUTTYPE, FB_OUTTYPE_DYNAMICLIB )
1352 if( value = FB_LANG_INVALID )
then
1361 dim as integer value =
any
1363 select case ucase(arg)
1365 value = FB_FPMODE_PRECISE
1367 value = FB_FPMODE_FAST
1375 dim as integer value =
any
1377 select case ucase(arg)
1379 value = FB_FPUTYPE_FPU
1381 value = FB_FPUTYPE_SSE
1392 select case(
lcase( arg ) )
1417 if( value = FB_LANG_INVALID )
then
1425 fbSetOption( FB_COMPOPT_OUTTYPE, FB_OUTTYPE_STATICLIB )
1435 dim as integer value =
any
1437 if( arg =
"inf" )
then
1438 value = FB_ERR_INFINITE
1440 value =
valint( arg )
1441 if( value <= 0 )
then
1472 dim as integer value =
any
1474 if (arg =
"max")
then
1480 elseif (value > 3)
then
1502 case "host" :
fbc.
print = PRINT_HOST
1503 case "target" :
fbc.
print = PRINT_TARGET
1515 fbSetOption( FB_COMPOPT_OUTTYPE, FB_OUTTYPE_OBJECT )
1524 fbSetOption( FB_COMPOPT_OUTTYPE, FB_OUTTYPE_OBJECT )
1538 fbSetOption(FB_COMPOPT_STACKSIZE,
valint(arg) * 1024)
1555 dim as integer target =
any
1562 if( os <> FB_HOST )
then
1563 #ifndef ENABLE_STANDALONE
1576 #ifndef ENABLE_STANDALONE
1593 case "x86_64",
"amd64"
1608 dim as integer value =
any
1610 select case (
ucase(arg))
1612 value = FB_VECTORIZE_NONE
1614 value = FB_VECTORIZE_NORMAL
1616 value = FB_VECTORIZE_INTRATREE
1627 dim as integer value = -2
1635 fbGetOption( FB_COMPOPT_PEDANTICCHK )
or FB_PDCHECK_PARAMMODE )
1639 fbGetOption( FB_COMPOPT_PEDANTICCHK )
or FB_PDCHECK_ESCSEQ )
1643 fbGetOption( FB_COMPOPT_PEDANTICCHK )
or FB_PDCHECK_NEXTVAR )
1647 fbGetOption( FB_COMPOPT_PEDANTICCHK )
or FB_PDCHECK_SIGNEDNESS )
1650 fbSetOption( FB_COMPOPT_PEDANTICCHK, FB_PDCHECK_DEFAULT )
1657 if( value >= -1 )
then
1674 select case(
lcase( arg ) )
1684 function parseOption(
byval opt
as zstring ptr)
as integer
1685 #macro CHECK(opttext,
optid)
1686 if (*opt = opttext)
then
1691 #macro ONECHAR(
optid)
1692 if (
cptr(
ubyte ptr, opt)[1] = 0)
then
1697 select case as const (
cptr(
ubyte ptr, opt)[0])
1820 if (
len(arg) = 0)
then
1829 if (
len(arg) = 0)
then
1834 select case (arg[0])
1836 dim as zstring ptr opt =
strptr(arg) + 1
1839 if (
cptr(
ubyte ptr, opt)[0] = 0)
then
1862 const MAX_LEVELS = 128
1863 static as integer reclevel = 0
1865 if (reclevel > MAX_LEVELS)
then
1872 arg =
right(arg,
len(arg) - 1)
1875 if (
len(arg) = 0)
then
1889 #if defined(
__FB_WIN32__)
or _
1890 defined(
__FB_DOS__)
or _
1891 defined(
__FB_CYGWIN__)
1927 dim as integer f =
freefile()
1928 if (
open(
filename,
for input,
as #f))
then
1936 while (
eof(f) =
FALSE)
1944 dim as integer length =
len(args)
1945 if (length = 0)
then
1949 dim as integer i = 0
1950 dim as integer quotech = 0
1953 dim as integer ch = args[i]
1955 select case as const (ch)
1957 if (quotech = 0)
then
1961 case asc(
""""),
asc(
"'")
1962 if (quotech = ch)
then
1965 elseif (quotech = 0)
then
1985 args =
right(args, length - i)
1992 sub hParseArgs(
byval argc
as integer,
byval argv
as zstring ptr ptr )
1997 for i
as integer = 1
to (argc - 1)
2017 if (
fbGetOption( FB_COMPOPT_FPUTYPE ) = FB_FPUTYPE_FPU )
then
2018 if(
fbGetOption( FB_COMPOPT_VECTORIZE ) >= FB_VECTORIZE_NORMAL )
or _
2019 (
fbGetOption( FB_COMPOPT_FPMODE ) = FB_FPMODE_FAST )
then
2020 errReportEx( FB_ERRMSG_OPTIONREQUIRESSSE,
"", -1 )
2032 #ifndef ENABLE_STANDALONE
2044 if( (
fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS)
and _
2045 (
not fbCpuTypeIsX86( )) )
then
2052 if( (
fbGetOption( FB_COMPOPT_BACKEND ) = FB_BACKEND_GAS)
and _
2053 (
not fbCpuTypeIsX86( )) )
then
2064 if( (
fbGetOption( FB_COMPOPT_BACKEND ) = FB_BACKEND_GAS)
and _
2065 (
not fbCpuTypeIsX86( )) )
then
2071 select case as const (
fbGetOption(FB_COMPOPT_TARGET))
2072 case FB_COMPTARGET_WIN32, FB_COMPTARGET_CYGWIN, FB_COMPTARGET_XBOX
2083 select case as const (
fbGetOption(FB_COMPOPT_TARGET))
2084 case FB_COMPTARGET_LINUX, FB_COMPTARGET_DARWIN, _
2085 FB_COMPTARGET_FREEBSD, FB_COMPTARGET_OPENBSD, _
2086 FB_COMPTARGET_NETBSD
2098 if( (
fbGetOption( FB_COMPOPT_BACKEND ) = FB_BACKEND_GAS)
and _
2100 errReportEx( FB_ERRMSG_GENGASWITHOUTINTEL,
"", -1 )
2119 #ifdef ENABLE_PREFIX
2120 fbc.
prefix = ENABLE_PREFIX + FB_HOST_PATHDIV
2123 #ifndef ENABLE_STANDALONE
2171 dim as string archprefix
2172 if( fbCpuTypeIs64bit( ) )
then
2173 archprefix =
"x86_64-"
2176 #ifdef ENABLE_STANDALONE
2182 dim as string fbname
2183 if(
fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS )
then
2189 fbname =
"freebasic"
2191 #ifdef ENABLE_SUFFIX
2192 fbname += ENABLE_SUFFIX
2209 if( fbCpuTypeIs64bit( ) )
then
2215 #ifndef ENABLE_STANDALONE
2236 if( objf <> NULL )
then
2259 byval stage
as integer _
2262 dim as zstring ptr ext =
any
2263 dim as string asmfile
2270 if( stage = 1 )
then
2274 case FB_BACKEND_LLVM
2287 byval is_main
as integer, _
2288 byval is_fbctinf
as integer _
2291 dim as integer prevlang =
any, prevouttype =
any, restarts =
any
2292 dim as string asmfile, pponlyfile
2301 ((
fbGetOption( FB_COMPOPT_BACKEND ) <> FB_BACKEND_GAS)
or _
2313 pponlyfile =
hStripExt( pponlyfile ) +
".pp.bas"
2320 print " -pp " + pponlyfile;
2323 print " (main module)";
2324 elseif( is_fbctinf )
then
2325 print " (FB compile-time info)";
2337 if( is_fbctinf )
then
2339 fbSetOption( FB_COMPOPT_OUTTYPE, FB_OUTTYPE_OBJECT )
2344 fbInit( is_main, restarts )
2346 if( is_fbctinf )
then
2380 if( is_fbctinf =
FALSE )
then
2394 dim as integer ismain =
any, checkmain =
any
2395 dim as string mainfile
2401 case FB_OUTTYPE_EXECUTABLE, FB_OUTTYPE_DYNAMICLIB
2414 if( checkmain )
then
2425 if( checkmain )
then
2443 if( module = NULL )
then
2451 byref xpmfile
as string, _
2452 byref code
as string _
2455 code += !
"\ndim shared as zstring ptr "
2456 code +=
"fb_program_icon_data"
2457 code += !
"(0 to ...) = _\n{ _\n"
2459 dim as integer f =
freefile( )
2460 if(
open( xpmfile,
for input,
as #f ) )
then
2468 if(
ucase(
ln ) <>
"/* XPM */" )
then
2479 while(
eof( f ) =
FALSE )
2486 ln =
left(
ln,
instr( 2,
ln,
"""" ) )
2489 if(
len(
ln ) > 0 )
then
2502 if( saw_rows =
FALSE )
then
2513 code += !
"extern as zstring ptr ptr fb_program_icon alias ""fb_program_icon""\n"
2514 code +=
"dim shared as zstring ptr ptr fb_program_icon = " & _
2515 !
"@fb_program_icon_data(0)\n"
2523 dim as string xpmfile, code
2524 dim as integer fo =
any
2568 dim as string ln, asmfile
2579 if( fbCpuTypeIs64bit( ) )
then
2586 ln +=
"-march=native "
2591 ln +=
"-S -nostdlib -nostdinc -Wall -Wno-unused-label " + _
2592 "-Wno-unused-function -Wno-unused-variable " + _
2593 "-Wno-unused-but-set-variable "
2600 ln +=
"-Werror-implicit-function-declaration "
2602 ln +=
"-O" +
str(
fbGetOption( FB_COMPOPT_OPTIMIZELEVEL ) ) +
" "
2605 ln +=
"-fno-strict-aliasing "
2611 ln +=
"-fno-math-errno "
2622 ln +=
"-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables "
2628 if(
fbGetOption( FB_COMPOPT_FPUTYPE ) = FB_FPUTYPE_SSE )
then
2629 ln +=
"-mfpmath=sse -msse2 "
2632 if(
fbGetOption( FB_COMPOPT_ASMSYNTAX ) = FB_ASMSYNTAX_INTEL )
then
2633 ln +=
"-masm=intel "
2636 case FB_BACKEND_LLVM
2637 if( fbCpuTypeIs64bit( ) )
then
2638 ln +=
"-march=x86-64 "
2643 ln +=
"-O" +
str(
fbGetOption( FB_COMPOPT_OPTIMIZELEVEL ) ) +
" "
2645 if(
fbGetOption( FB_COMPOPT_ASMSYNTAX ) = FB_ASMSYNTAX_INTEL )
then
2646 ln +=
"--x86-asm-syntax=intel "
2652 ln +=
"-o """ + asmfile +
""""
2658 case FB_BACKEND_LLVM
2676 if( fbCpuTypeIs64bit( ) )
then
2683 ln +=
"--strip-local-absolute "
2727 dim as string oldinclude =
trim(
environ(
"INCLUDE" ) )
2729 (FB_HOST_PATHDIV +
"win" + FB_HOST_PATHDIV +
"rc")
2731 dim as string ln =
"/ni /nw /o "
2740 if(
len( oldinclude ) > 0 )
then
2741 setenviron "INCLUDE=" + oldinclude
2744 if( need_rename )
then
2745 dim as string badname = *rc->
objfile
2748 function = (
name( badname, *rc->
objfile ) = 0)
2758 dim as string ln =
"--output-format=coff "
2784 if(
fbGetOption( FB_COMPOPT_BACKEND ) <> FB_BACKEND_GAS )
then
2796 dim as integer fo =
any
2800 fbctinf.
srcfile = FB_INFOSEC_BASNAME
2810 if(
open( fbctinf.
srcfile,
for output,
as #fo ) )
then
2821 if(
fbGetOption( FB_COMPOPT_BACKEND ) <> FB_BACKEND_GAS )
then
2833 dim as string ln =
"-rsc " + QUOTE +
fbc.
outname + (QUOTE +
" ")
2840 ln += QUOTE + FB_INFOSEC_OBJNAME + QUOTE +
" "
2862 #ifndef ENABLE_STANDALONE
2868 if(
fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DOS )
then
2877 case FB_COMPTARGET_DOS
2883 case FB_COMPTARGET_WIN32
2897 if(
fbGetOption( FB_COMPOPT_MULTITHREADED ) )
then
2903 select case as const fbGetOption( FB_COMPOPT_TARGET )
2904 case FB_COMPTARGET_CYGWIN
2915 case FB_COMPTARGET_DARWIN
2919 case FB_COMPTARGET_DOS
2923 #ifdef ENABLE_STANDALONE
2932 case FB_COMPTARGET_FREEBSD
2940 case FB_COMPTARGET_LINUX
2978 case FB_COMPTARGET_NETBSD
2981 case FB_COMPTARGET_OPENBSD
2989 case FB_COMPTARGET_WIN32
3009 case FB_COMPTARGET_XBOX
3034 print "usage: fbc [options] <input files>"
3035 print "input files:"
3036 print " *.a = static library, *.o = object file, *.bas = source"
3037 print " *.rc = resource script, *.res = compiled resource (win32)"
3038 print " *.xpm = icon resource (*nix/*bsd)"
3040 print " @<file> Read more command line arguments from a file"
3041 print " -a <file> Treat file as .o/.a input file"
3042 print " -arch <type> Set target architecture (default: 486)"
3043 print " -asm att|intel Set asm format (-gen gcc)"
3044 print " -b <file> Treat file as .bas input file"
3045 print " -c Compile only, do not link"
3046 print " -C Preserve temporary .o files"
3047 print " -d <name>[=<val>] Add a global #define"
3048 print " -dll Same as -dylib"
3049 print " -dylib Create a DLL (win32) or shared library (*nix/*BSD)"
3050 print " -e Enable runtime error checking"
3051 print " -ex -e plus RESUME support"
3052 print " -exx -ex plus array bounds/null-pointer checking"
3053 print " -export Export symbols for dynamic linkage"
3054 print " -forcelang <name> Override #lang statements in source code"
3055 print " -fpmode fast|precise Select floating-point math accuracy/speed"
3056 print " -fpu x87|sse Set target FPU"
3057 print " -g Add debug info"
3058 print " -gen gas|gcc|llvm Select code generation backend"
3059 print " [-]-help Show this help output"
3060 print " -i <path> Add an include file search path"
3061 print " -include <file> Pre-#include a file for each input .bas"
3062 print " -l <name> Link in a library"
3063 print " -lang <name> Select FB dialect: deprecated, fblite, qb"
3064 print " -lib Create a static library"
3065 print " -m <name> Specify main module (default if not -c: first input .bas)"
3066 print " -map <file> Save linking map to file"
3067 print " -maxerr <n> Only show <n> errors"
3068 print " -mt Use thread-safe FB runtime"
3069 print " -nodeflibs Do not include the default libraries"
3070 print " -noerrline Do not show source context in error messages"
3071 print " -o <file> Set .o (or -pp .bas) file name for prev/next input file"
3072 print " -O <value> Optimization level (default: 0)"
3073 print " -p <path> Add a library search path"
3074 print " -pp Write out preprocessed input file (.pp.bas) only"
3075 print " -prefix <path> Set the compiler prefix path"
3076 print " -print host|target Display host/target system name"
3077 print " -print x Display output binary/library file name (if known)"
3078 print " -profile Enable function profiling"
3079 print " -r Write out .asm (-gen gas) or .c (-gen gcc) only"
3080 print " -rr Write out the final .asm only"
3081 print " -R Preserve the temporary .asm/.c file"
3082 print " -RR Preserve the final .asm file"
3083 print " -s console|gui Select win32 subsystem"
3084 print " -static Prefer static libraries over dynamic ones when linking"
3085 print " -t <value> Set .exe stack size in kbytes, default: 1024 (win32/dos)"
3086 print " -target <name> Set cross-compilation target"
3087 print " -title <name> Set XBE display title (xbox)"
3088 print " -v Be verbose"
3089 print " -vec <n> Automatic vectorization level (default: 0)"
3090 print " [-]-version Show compiler version"
3091 print " -w all|pedantic|<n> Set min warning level: all, pedantic or a value"
3092 print " -Wa <a,b,c> Pass options to 'as' (-gen gas or -gen llvm)"
3093 print " -Wc <a,b,c> Pass options to 'gcc' (-gen gcc) or 'llc' (-gen llvm)"
3094 print " -Wl <a,b,c> Pass options to 'ld'"
3095 print " -x <file> Set output executable/library file name"
3096 print " -z gosub-setjmp Use setjmp/longjmp to implement GOSUB"
3100 if(
len( config ) > 0 )
then
3107 dim as string config
3109 print "FreeBASIC Compiler - Version " + FB_VERSION + _
3110 " (" + FB_BUILD_DATE +
") for " + FB_HOST
3111 print "Copyright (C) 2004-2013 The FreeBASIC development team."
3113 #ifdef ENABLE_STANDALONE
3117 #ifdef ENABLE_PREFIX
3121 if(
len( config ) > 0 )
then
3128 if(
__FB_ARGC__ = 1 )
then
3158 case PRINT_HOST, PRINT_TARGET, PRINT_X
3181 if(
fbGetOption( FB_COMPOPT_BACKEND ) <> FB_BACKEND_GAS )
then
3200 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_OBJECT )
then
3214 if(
fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_STATICLIB )
then