Comments (7)
On further investigation, it seems this is the issue, from CMLFS/3-chroot/008-Adjust_Toolchain
:
echo " --sysroot=/usr -Wl,-dynamic-linker /lib/ld-musl-$(uname -m).so.1" > \
/llvmtools/bin/$(uname -m)-cmlfs-linux-musl.cfg
Here we are manually instructing clang to always insert -dynamic-linker
, but clang can already build working dynamic libraries with the correct Interpreter:
# echo "int main(){}" > t.c
# clang -o t t.c --verbose -Wl,--verbose
"/llvmtools/bin/clang-12" -cc1 -triple x86_64-pc-linux-musl -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name t.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /llvmtools/lib/clang/12.0.0 -isysroot /llvmtools -internal-isystem /llvmtools/usr/local/include -internal-externc-isystem /llvmtools/include -internal-externc-isystem /llvmtools/usr/include -internal-isystem /llvmtools/lib/clang/12.0.0/include -fdebug-compilation-dir /sources/src/utmps-system/temp -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/t-edcaf0.o -x c t.c
# file t
t: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped
If I remove the -dynamic-linker
section from the config file,
echo " --sysroot=/usr" > /llvmtools/bin/$(uname -m)-cmlfs-linux-musl.cfg
And rebuild:
# x86_64-cmlfs-linux-musl-clang -o t t.c --verbose -Wl,--verbose
Configuration file: /llvmtools/bin/x86_64-cmlfs-linux-musl.cfg
"/llvmtools/bin/clang-12" -cc1 -triple x86_64-cmlfs-linux-musl -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name t.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /llvmtools/lib/clang/12.0.0 -isysroot /usr -internal-isystem /usr/usr/local/include -internal-externc-isystem /usr/include -internal-externc-isystem /usr/usr/include -internal-isystem /llvmtools/lib/clang/12.0.0/include -fdebug-compilation-dir /sources/src/utmps-system/temp -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/t-9e1d1a.o -x c t.c
# file t
t: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped
Once this change has been made, with CC=x86_64-cmlfs-linux-musl-clang
:
# file utmps-utmpd
utmps-utmpd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
# ./utmps-utmpd
utmps-utmpd: fatal: unable to get $IPCREMOTEEUID from environment
utmps
succeeds to build, and works without Segmentation Fault
from cmlfs.
I created CMLFS/3-chroot/008-Adjust_Toolchain
because the llvmtools toolchain produced binaries that looked for an interpreter in /llvmtools instead on the final system root.
LLVM docs don't seem to be much help when trying to build sandboxed toolchains.
from cmlfs.
I had trouble starting up a new build with LLVM-12.x and moved on to LLVM-15.0.5. Of course, there seems to be drastic changes in LLVM source from 12.x to 15.x which required me to rethink the method to cross compile clang.
After many painful days of failure, I got LLVM-15.0.5 to cross compile. By now, stage 1 clang [installed in llvmtools] links all binaries with -dynamic-linker /lib/ld-musl-$(uname -m).so.1
without a config file. So, stage 1 clang only needs to be re-configured to change sysroot from /llvmtools
to /usr
... just as you have mentioned above
from cmlfs.
This has been addressed via commit 0bfc298
from cmlfs.
commit bc471a8 now recognizes this change
from cmlfs.
Issue still present.
Stage1 clang outputs compiled code that uses the dynamic linux loader in /llvmtools/lib
. After the system libc [musl] is built, then stage1 clang needs to be reconfigured to produce compiled code that uses the dynamic linux loader in /lib
Either I add patchelf
to llvmtools to manually patch shared binaries to use the dynamic linux loader in /lib
[until the stage2 clang, the final system's compiler is built] OR .... compile stage1 clang twice, one per dynamic loader path.
from cmlfs.
Stage0 clang now builds the final system's default compiler which by default produces binaries that use the dynamic linker in /lib/ld-musl-$(uname m).so.1
as this change was done with commit 550cf2c
Now when utmps is built [in chroot], the final system's clang builds it with no cfg. Therefore, static binaries are not built with -dynamic-linker
.
This change is present on the mussel-bootsrapped
branch. Once I confirm this branch can indeed build a usable CMLFS system, I will merge it into master and CMLFS will then be built with mussel.
from cmlfs.
Related Issues (20)
- References to `systemctl` during boot HOT 2
- Gperf fails to compile HOT 43
- Broken stage2 (final system) clang+LLVM HOT 3
- Could we also have Heirloom NG as an alternative to GNU Coreutils in the future? HOT 63
- Python3 need to be rebuilt after final system clang is built HOT 8
- Clarity on CMLFS_TARGET at 1-cgnutools/4-musl HOT 2
- Compiler Warning: "-fuse-ld=' taking a path is deprecated"
- LLVM Compilation Failed HOT 1
- Unable to Compile Kernel HOT 25
- What are the packages that cannot be build without GCC? HOT 4
- Fail at Stage-0 (1-Mussel) HOT 6
- What is the state of CMLFS methods for cross-compiling? HOT 34
- Patch for musl's utmp.h is incomplete HOT 5
- OpenSSL needs certificates HOT 1
- LLVM-17.0.5: Stage 2 Clang has sysroot set as /llvmtools HOT 11
- Udev [from systemd] wont configure for final system; expects util-linux installed HOT 2
- Mention of `systemd-hwdb` when executing `udevadm` HOT 1
- Drop GNU's cpio for bsdcpio [provided by libarchive] HOT 14
- Autotools Broken -- `autoreconf` runs but exits with errors HOT 1
- Binutils: libctf fails to compile HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmlfs.