Uh oh!
There was an error while loading. Please reload this page.
stage2: support dynamically linking musl libc - #7406
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| var buf: [4096]u8 = undefined; | ||
| // Sample input line: | ||
| // 00000000000241b0 g DF .text 000000000000001b copy_file_range |
There was a problem hiding this comment.
If you want to do some more filtering check out glibc's abilist.awk (see here. Musl's libc.so is quite tame if compared to glibc's one so most of that is not needed (yet?)/
One thing that's wrong even in the glibc parsing scripts is the use of .type N, @function;, that's ok for functions but not really ok for other symbol kinds (eg. environ is marked as DO instead of DF in objdump's output).
Since the symbol types "percolate" to the final object this may be a problem...
Here's the objdump's output of a simple program referencing environ, the first part is when musl's libc is used, the second when the generated libc.so is used instead:
5: 0000000000004028 8 OBJECT WEAK DEFAULT 20 _environ
6: 0000000000004028 8 OBJECT WEAK DEFAULT 20 environ
7: 0000000000004028 8 OBJECT GLOBAL DEFAULT 20 __environ
9: 0000000000004028 8 OBJECT WEAK DEFAULT 20 ___environ
48: 0000000000004028 8 OBJECT GLOBAL DEFAULT 20 __environ
50: 0000000000004028 8 OBJECT WEAK DEFAULT 20 environ
523: 0000000000001016 0 FUNC GLOBAL DEFAULT 6 _environ
552: 0000000000001016 0 FUNC GLOBAL DEFAULT 6 __environ
703: 0000000000001016 0 FUNC GLOBAL DEFAULT 6 environ
820: 0000000000001016 0 FUNC GLOBAL DEFAULT 6 ___environ
Will this be a problem? In theory yes, every tool that checks the symbol type will be extremely confused by this.
Uh oh!
There was an error while loading. Please reload this page.
ifreund
commented
Dec 12, 2020
Got rid of the code generating |
LemonBoy
commented
Dec 12, 2020
I'll drop the big question, how do we integrate this new target in the testing setup? |
ifreund
commented
Dec 12, 2020
The stubs are now generated with proper types and the output is sorted alphabetically to make diffs nicer when updating in the future. I haven't implemented any filtering beyond skipping non-dynamic symbols as I'm not sure if it would be worth it. |
ifreund
commented
Dec 12, 2020
Actually if I'm understanding correctly the drone CI is already testing this target by default as it runs on alpine which uses musl as the system libc. |
ifreund
commented
Dec 12, 2020
Now only difference (aside from addresses) in the output of |
ifreund
commented
Dec 12, 2020
I've run into an issue. If I delete the stub I'm investigating a fix. |
andrewrk
commented
Dec 12, 2020
Hmm this should be solved by passing the dynamic linker path in the link/Elf.zig code |
ifreund
commented
Dec 12, 2020
I believe we already are with |
LemonBoy
commented
Dec 12, 2020
What's the output of |
Before removing the global cache dir: After: |
LemonBoy
commented
Dec 12, 2020
The problem is the full path, you want only |
|
ifreund
commented
Dec 12, 2020
Setting the soname to |
The |
andrewrk
left a comment
There was a problem hiding this comment.
Really nice work here! This is already in a mergeable state, but I do have a couple requests for ya
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
If targeting the native OS and the system libc is musl, link against it dynamically by default.
ifreund
commented
Dec 12, 2020
Fixed both comments. For the record, to diff the output of If all is well the diff command will give no output |
stage2: support dynamically linking musl libc
Closes#5364
This is a draft as I still need to (partially) automate generation of thelibc.sfile for easier maintenance.