Skip to content

Commit

Permalink
fbc: allow llvm backend for PIC builds; fix some comments about PIC
Browse files Browse the repository at this point in the history
  • Loading branch information
rversteegen authored and jayrm committed Jan 2, 2024
1 parent f9c0d70 commit 0892969
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/compiler/fbc.bas
Expand Up @@ -2782,8 +2782,7 @@ end sub

'' Whether a target needs shared libraries to be built with PIC.
'' (Note: Android 5.0+ also need executables to be built with PIC (gcc -pie argument),
'' but Android 4.0- don't support PIE executables. So it's up to the user to decide
'' and pass that argument to gcc.)
'' but Android <4.1 didn't support PIE executables. We assume 4.1+.)
private function hTargetNeedsPIC( ) as integer
function = FALSE
if( fbGetCpuFamily( ) <> FB_CPUFAMILY_X86 ) then
Expand All @@ -2797,7 +2796,7 @@ private function hTargetNeedsPIC( ) as integer
else
'' On android-x86, PIC is necessary even to access globals in dynamic
'' libraries, because the runtime linker doesn't support usual relocation types.
'' GCC default to -fPIC anyway, but we need to be aware of whether PIC is used.
'' GCC defaults to -fPIC anyway, but we need to be aware of whether PIC is used.
if( fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_ANDROID ) then
function = TRUE
end if
Expand Down Expand Up @@ -2874,7 +2873,8 @@ private sub hCheckArgs()
fbcEnd( 1 )
end if

'' 4.5. Enable -pic automatically when building a shared library on Unixes
'' 4.5. Enable -pic automatically when building a Unix shared library
'' or Android executable (required on Android 5+)
if( (fbGetOption( FB_COMPOPT_OUTTYPE ) = FB_OUTTYPE_DYNAMICLIB) or _
(fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_ANDROID) ) then
if( hTargetNeedsPIC( ) ) then
Expand Down Expand Up @@ -2906,8 +2906,10 @@ private sub hCheckArgs()
else
fbSetOption( FB_COMPOPT_BACKEND, FB_BACKEND_GCC )
end if
'' gas doesn't currently support -pic
if( fbGetOption( FB_COMPOPT_PIC ) ) then
'' gas/gas64 doesn't currently support PIC
if( ((fbGetOption( FB_COMPOPT_BACKEND ) = FB_BACKEND_GAS) or _
(fbGetOption( FB_COMPOPT_BACKEND ) = FB_BACKEND_GAS64)) and _
fbGetOption( FB_COMPOPT_PIC ) ) then
fbSetOption( FB_COMPOPT_BACKEND, FB_BACKEND_GCC )
end if

Expand Down

0 comments on commit 0892969

Please sign in to comment.