Skip to content
Open
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
46 changes: 46 additions & 0 deletions src/compiler/fbc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,35 @@ private function fbcBuildPathToLibFile( byval file as zstring ptr ) as string
end if
#endif

'' FreeBSD: Prefer base system locations for CRT objects.
'' Do this *before* invoking gcc -print-file-name, because on some setups
'' gcc may return just the basename (no sysroot configured).
if( fbGetCpuFamily( ) = FB_CPUFAMILY_PPC64 ) then
select case lcase( *file )
case "crt1.o", "gcrt1.o", "crti.o", "crtn.o", _
"crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"
dim as string tryfile

tryfile = "/usr/lib/" + *file
if( hFileExists( tryfile ) ) then
function = tryfile
exit function
end if

tryfile = "/usr/lib64/" + *file
if( hFileExists( tryfile ) ) then
function = tryfile
exit function
end if

tryfile = "/lib/" + *file
if( hFileExists( tryfile ) ) then
function = tryfile
exit function
end if
end select
end if

'' Does it exist in our lib/?
if( hFileExists( found ) ) then
'' Overrides anything else
Expand Down Expand Up @@ -4191,6 +4220,22 @@ private sub hSetDefaultLibPaths( )
'' and the current path
fbcAddDefLibPath( "." )

''
'' FreeBSD base system libraries live in /usr/lib and /lib.
'' When fbc invokes ld directly (not via cc), it must provide these
'' search paths explicitly so -lc/-lm/-lpthread/-lncurses/-lgcc can
'' be resolved by the linker.
''
'' Only add them for native builds (no --sysroot); cross builds should
'' rely on --sysroot or explicit -p/-P paths.
''
if( (fbGetCpuFamily( ) = FB_CPUFAMILY_PPC64) andalso (len( fbc.sysroot ) = 0) ) then
fbcAddDefLibPath( "/usr/lib" )
fbcAddDefLibPath( "/usr/lib64" )
fbcAddDefLibPath( "/usr/local/lib" )
fbcAddDefLibPath( "/lib" )
end if

#ifndef ENABLE_STANDALONE
'' Add gcc's private lib directory, to find libgcc
'' This is for installing into Unix-like systems, and not for
Expand Down Expand Up @@ -4276,6 +4321,7 @@ private sub hAddDefaultLibs( )
defined(__FB_OPENBSD__) or _
defined(__FB_NETBSD__)
fbcAddDefLibPath( "/usr/X11R6/lib" )
fbcAddDefLibPath( "/usr/local/lib" )
#endif

#if defined(__FB_DARWIN__) and defined(ENABLE_XQUARTZ)
Expand Down