/usr/local/bin/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory
Summary
While trying to build fpc 3.2.3 from source, the build fails with the following error: /usr/local/bin/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory.
System Information
- Operating system: Linux (ChromeOS <M125)
- Processor architecture: x86_64
- Compiler version: 3.2.3
Steps to reproduce
sudo docker run --platform linux/amd64 --rm -it satmandu/crewbuild:amd64
(once inside the container)
rm -f "$CREW_PREFIX/etc/bash.d/git" "$CREW_PREFIX/etc/bash.d/git-prompt.sh" && source ~/.bashrccdgit clone https://gitlab.com/freepascal.org/fpc/source.gitcd sourcegit checkout 3.2.3crew install fpcln -s /usr/local/lib/fpc/3.2.2/ppcx64 /usr/local/bin/ppcx64make all -j8 OVERRIDEVERSIONCHECK=1 OPT='-k-L/usr/local/lib64'make zipinstallyes | crew remove fpcrm -f /usr/local/bin/ppcx64rm -rf /usr/local/lib/fpctar xC /usr/local -f fpc-3.2.3.x86_64-linux.tar.gzln -s /usr/local/lib/fpc/3.2.3/ppcx64 /usr/local/bin/ppcx64/usr/local/lib/fpc/3.2.3/samplecfg /usr/local/lib/fpc/3.2.3/ /usr/local/etcsed -i '/# searchpath for libraries/a\-Fl/usr/local/lib64' /usr/local/etc/fpc.cfgexport PPC_CONFIG_PATH=/usr/local/etcmake cleanmake all -j8 OVERRIDEVERSIONCHECK=1
What is the current bug behavior?
The build fails.
What is the expected (correct) behavior?
The build succeeds.
Relevant logs and/or screenshots
make[3]: Leaving directory '/home/chronos/user/source/packages/fpmkunit'
/home/chronos/user/source/compiler/ppcx64 fpmake.pp -Fu/home/chronos/user/source/packages/fpmkunit/units_bs/x86_64-linux -Fu/home/chronos/user/source/rtl/units/x86_64-linux
Free Pascal Compiler version 3.2.3 [2024/07/03] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling fpmake.pp
fpmake.pp(16,3) Note: Local variable "T" is assigned but never used
Linking fpmake
/usr/local/bin/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory
fpmake.pp(58,1) Error: Error while linking
fpmake.pp(58,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make[2]: *** [Makefile:1719: fpmake] Error 1
make[2]: Leaving directory '/home/chronos/user/source/packages'
make[1]: *** [Makefile:2682: packages_smart] Error 2
make[1]: Leaving directory '/home/chronos/user/source'
make: *** [Makefile:2837: build-stamp.x86_64-linux] Error 2
Running the ppcx64 command separately:
chronos@14cb86fb8359 ~/source $ ppcx64 fpmake.pp -Fu/home/chronos/user/source/packages/fpmkunit/units_bs/x86_64-linux -Fu/home/chronos/user/source/rtl/units/x86_64-linux
Free Pascal Compiler version 3.2.3 [2024/07/03] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling fpmake.pp
fpmake.pp(16,3) Note: Local variable "T" is assigned but never used
fpmake.pp(72,52) Warning: Local variable "P" does not seem to be initialized
fpmake.pp(12,3) Note: Local variable "T" is assigned but never used
fpmake.pp(12,3) Note: Local variable "T" is assigned but never used
fpmake.pp(12,3) Note: Local variable "T" is assigned but never used
fpmake.pp(12,3) Note: Local variable "T" is assigned but never used
fpmake.pp(12,3) Note: Local variable "T" is assigned but never used
fpmake.pp(12,6) Note: Local variable "T" not used
Linking fpmake
/usr/local/bin/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory
fpmake.pp(53,1) Error: Error while linking
fpmake.pp(53,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Running it verbosely: log
Possible fixes
The build succeeds if I pass OPT='-k-L/usr/local/lib64' to the make all call.
libc_nonshared.a isn't present in /usr/lib64, but I assumed that adding it to the list of directories to search via -Fl/usr/local/lib64 would result in it getting found, rather than having to manually tell the linker about it via -k-L/usr/local/lib64.
Also, while -Fl/usr/local/lib64 isn't passed directly, it is present in fpc.cfg, as can be seen in the verbose log.
Unless I am missing something, the fix here would probably be to ensure that passing a library directory via -Fl results in it getting passed to the linker as well.