-
-
Notifications
You must be signed in to change notification settings - Fork 528
Open
Description
Hi,
gcc-trunk (g++-16 (GCC) 16.0.1 20260115 (experimental)) currently does not work with mold:
# test.cpp = `int main() {}`
g++-16 -fuse-ld=mold test.cpp
mold: fatal: /usr/local/stow/gcc-16/lib64/libatomic_asneeded.so:3: INPUT ( AS_NEEDED( -latomic ) )
^ library not found: AS_NEEDED
collect2: error: ld returned 1 exit statusBackground
GCC added some linker scripts (e.g., INPUT ( AS_NEEDED ( -latomic ) )):
(Edit) The bug was also independently filed in GCC's bug tracker and now links to this issue.
Stacktrace
mold::Script<mold::X86_64>::resolve_path(mold::Script<mold::X86_64> * this, mold::Script<mold::X86_64> * this@entry, std::__1::string_view tok, bool check_target) (\mold\src\linker-script.cc:185)
mold::Script<mold::X86_64>::get_script_output_type(mold::Script<mold::X86_64> * this) (\mold\src\linker-script.cc:253)
mold::detect_machine_type<mold::X86_64>(mold::Context<mold::X86_64> & ctx) (\mold\src\main.cc:153)
mold::mold_main<mold::X86_64>(int argc, char ** argv) (\mold\src\main.cc:295)
libc.so.6![Unknown/Just-In-Time compiled code] (Unknown Source:0)
libc.so.6!__libc_start_main (Unknown Source:0)
_start (Unknown Source:0)Misc
The error doesn't happen if:
-mis set, or- first entry in
INPUTis a a path to a lib or uses-l
Lines 294 to 295 in 17956fd
| if (ctx.arg.emulation.empty()) | |
| ctx.arg.emulation = detect_machine_type(ctx, file_args); |
Lines 152 to 153 in 17956fd
| if (std::string_view target = | |
| Script(ctx, rctx, mf).get_script_output_type(); |
Lines 251 to 253 in 17956fd
| if (tok.size() >= 3 && (tok[0] == "INPUT" || tok[0] == "GROUP") && | |
| tok[1] == "(") | |
| if (MappedFile *mf = resolve_path(tok[2], false)) |
Trying to treat AS_NEEDED as a path then results in the error.
The code probably needs to handle groups, similar to what read_group does.
d7d1cd
Metadata
Metadata
Assignees
Labels
No labels