Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM backend: on Windows use clang instead of llc #279

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ Version 1.08.0
- C backend: inline asm - don't add rsp/esp to the clobber list, it's deprecated in newer gcc versions and silently ignored in older versions
- github #309: token pasting operator '##' allows pasting of single '_' characters
- fbc: re-add __FB_GUI__ intrinsic define - the change was clobbered for a time during fbc 1.08.0 development after basic-macros were added
- llvm backend on Windows invokes clang.exe instead of llc.exe (which usually doesn't exist)


Version 1.07.0
Expand Down
50 changes: 45 additions & 5 deletions src/compiler/fbc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -3613,6 +3613,11 @@ private function hCompileXpm( ) as integer
function = TRUE
end function

#if defined( __FB_WIN32__ )
'' LLVM official Windows binary distributions lack llc.exe, use clang instead
#define NO_LLC
#endif

private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as integer
dim as string ln, asmfile

Expand Down Expand Up @@ -3792,13 +3797,34 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
end select

case FB_BACKEND_LLVM
#ifdef NO_LLC
ln += "-S "
'' Silence "overriding the module target triple" warning. Maybe warning
'' that the target should be declared in the .ll instead.
ln += "-Wno-override-module "
'' Tell clang we're using system as, so don't use extensions in the asm
ln += "-no-integrated-as "
#endif

select case( fbGetCpuFamily( ) )
case FB_CPUFAMILY_X86
ln += "-march=x86 "
#ifdef NO_LLC
ln += "--target=i686 "
#else
ln += "-march=x86 "
#endif
case FB_CPUFAMILY_X86_64
ln += "-march=x86-64 "
#ifdef NO_LLC
ln += "--target=x86_64 "
#else
ln += "-march=x86-64 "
#endif
case FB_CPUFAMILY_ARM
ln += "-march=arm "
#ifdef NO_LLC
ln += "--target=armv7a "
#else
ln += "-march=arm "
#endif
case FB_CPUFAMILY_AARCH64
'' From the GCC manual:
'' -march=name
Expand Down Expand Up @@ -3832,6 +3858,12 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
'' is tuned to perform well across a range of target
'' processors implementing the target architecture.

#ifdef NO_LLC
ln += "--target=armv8a "
#else
ln += "-march=armv8-a "
#endif

ln += "-march=armv8-a "
case FB_CPUFAMILY_PPC
ln += "-mcpu=powerpc "
Expand All @@ -3850,7 +3882,11 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
select case( fbGetCpuFamily( ) )
case FB_CPUFAMILY_X86, FB_CPUFAMILY_X86_64
if( fbGetOption( FB_COMPOPT_ASMSYNTAX ) = FB_ASMSYNTAX_INTEL ) then
ln += "--x86-asm-syntax=intel "
#ifdef NO_LLC
ln += "-masm=intel "
#else
ln += "--x86-asm-syntax=intel "
#endif
end if
end select

Expand All @@ -3873,7 +3909,11 @@ private function hCompileStage2Module( byval module as FBCIOFILE ptr ) as intege
ccompiler = FBCTOOL_CLANG
function = fbcRunBin( "compiling C", ccompiler, ln )
case FB_BACKEND_LLVM
ccompiler = FBCTOOL_LLC
#ifdef NO_LLC
ccompiler = FBCTOOL_CLANG
#else
ccompiler = FBCTOOL_LLC
#endif
function = fbcRunBin( "compiling LLVM IR", ccompiler, ln )
end select
end function
Expand Down