118118 FBCTOOL_LD
119119 FBCTOOL_GCC
120120 FBCTOOL_LLC
121+ FBCTOOL_CLANG
121122 FBCTOOL_DLLTOOL
122123 FBCTOOL_GORC
123124 FBCTOOL_WINDRES
@@ -132,7 +133,7 @@ end enum
132133
133134static shared as zstring * 16 toolnames( 0 to FBCTOOL__COUNT- 1 ) = _
134135{ _
135- "as" , "ar" , "ld" , "gcc" , "llc" , "dlltool" , "GoRC" , "windres" , "cxbe" , "dxe3gen" , _
136+ "as" , "ar" , "ld" , "gcc" , "llc" , "clang" , " dlltool", "GoRC" , "windres" , "cxbe" , "dxe3gen" , _
136137 "emcc" , _
137138 "emar" , _
138139 "emcc" , _
@@ -2954,6 +2955,11 @@ private function hCompileXpm( ) as integer
29542955 function = TRUE
29552956end function
29562957
2958+ # if __FB_WIN32__
2959+ '' LLVM official Windows binary distributions lack llc.exe, use clang instead
2960+ #define NO_LLC
2961+ # endif
2962+
29572963private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as integer
29582964 dim as string ln, asmfile
29592965
@@ -3057,13 +3063,34 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
30573063 end select
30583064
30593065 case FB_BACKEND_LLVM
3066+ #ifdef NO_LLC
3067+ ln += "-S "
3068+ '' Silence "overriding the module target triple" warning. Maybe warning
3069+ '' that the target should be declared in the .ll instead.
3070+ ln += "-Wno-override-module "
3071+ '' Tell clang we're using system as, so don't use extensions in the asm
3072+ ln += "-no-integrated-as "
3073+ # endif
3074+
30603075 select case ( fbGetCpuFamily( ) )
30613076 case FB_CPUFAMILY_X86
3062- ln += "-march=x86 "
3077+ #ifdef NO_LLC
3078+ ln += "--target=i686 "
3079+ # else
3080+ ln += "-march=x86 "
3081+ # endif
30633082 case FB_CPUFAMILY_X86_64
3064- ln += "-march=x86-64 "
3083+ #ifdef NO_LLC
3084+ ln += "--target=x86_64 "
3085+ # else
3086+ ln += "-march=x86-64 "
3087+ # endif
30653088 case FB_CPUFAMILY_ARM
3066- ln += "-march=arm "
3089+ #ifdef NO_LLC
3090+ ln += "--target=armv7a "
3091+ # else
3092+ ln += "-march=arm "
3093+ # endif
30673094 case FB_CPUFAMILY_AARCH64
30683095 '' From the GCC manual:
30693096 '' -march=name
@@ -3097,7 +3124,11 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
30973124 '' is tuned to perform well across a range of target
30983125 '' processors implementing the target architecture.
30993126
3100- ln += "-march=armv8-a "
3127+ #ifdef NO_LLC
3128+ ln += "--target=armv8a "
3129+ # else
3130+ ln += "-march=armv8-a "
3131+ # endif
31013132 end select
31023133
31033134 if ( fbGetOption( FB_COMPOPT_PIC ) ) then
@@ -3109,7 +3140,11 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
31093140 select case ( fbGetCpuFamily( ) )
31103141 case FB_CPUFAMILY_X86, FB_CPUFAMILY_X86_64
31113142 if ( fbGetOption( FB_COMPOPT_ASMSYNTAX ) = FB_ASMSYNTAX_INTEL ) then
3112- ln += "--x86-asm-syntax=intel "
3143+ #ifdef NO_LLC
3144+ ln += "-masm=intel "
3145+ # else
3146+ ln += "--x86-asm-syntax=intel "
3147+ # endif
31133148 end if
31143149 end select
31153150
@@ -3127,7 +3162,12 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
31273162 end if
31283163 function = fbcRunBin( "compiling C" , gcc, ln )
31293164 case FB_BACKEND_LLVM
3130- function = fbcRunBin( "compiling LLVM IR" , FBCTOOL_LLC, ln )
3165+ #ifdef NO_LLC
3166+ const compiler = FBCTOOL_CLANG
3167+ # else
3168+ const compiler = FBCTOOL_LLC
3169+ # endif
3170+ function = fbcRunBin( "compiling LLVM IR" , compiler, ln )
31313171 end select
31323172end function
31333173
0 commit comments