-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
find_linux_crt_begin
returns wrong path
#1734
Comments
It will pick the first match. Given the amount of different setups on Linux, there is no way to know what's really right. This is isn't the first code attempt to detect the correct location of the crt, which actually won't be correct for things like Musl installs. The current code represents a best effort with the --linux-* being intended to solve the problem when the heuristics fail. If you are interested in contributing some improvement to this code then you're very welcome to do so, but it takes some love from linux users to improve. The current solution has been programmed and tested using CI to debug / test. Extremely time consuming. |
I hadn’t really considered how messy Linux can be in this regard. Honestly, I don’t know much about glibc/musl or crt, but given that the current approach assumes static const char *get_linux_crt_begin_arch_glob(void) {
switch (compiler.build.arch_os_target) {
// It might be <arch>-linux-gnu or <arch>-pc-linux-gnu
case LINUX_X64:
return "/usr/lib/gcc/x86_64*linux*/*/crtbegin.o";
case LINUX_X86:
return "/usr/lib/gcc/i686*linux*/*/crtbegin.o";
case LINUX_AARCH64:
return "/usr/lib/gcc/aarch64*linux*/*/crtbegin.o";
case LINUX_RISCV32:
case LINUX_RISCV64:
default:
return "/usr/lib/gcc/*/*/crtbegin.o";
}
} It’s not the cleanest solution and feels a bit hacky, but as I mentioned, I’m not super familiar with the topic or the codebase. |
I've found this for musl on debian:
I guess the corresponding notion of sourcehttps://packages.debian.org/bookworm/amd64/musl-dev/filelist |
I've been playing with Alpine Linux. |
The function
find_linux_crt_begin
returns an incorrect path if there are multiple GCC installations with alphabetically preceding names on the systemHost:
Installed GCC:
The function returns the path to the crtbegin inside aarch64-linux-gnu instead of the path for the host architecture (x86_64-pc-linux-gnu) or the target specified in project.json
Steps to Reproduce
$ c3c init dyn_lib --template dynamic_lib $ cd dyn_lib $ c3c build
Log:
This happens even with the target specified in
project.json
The problem itself is in the function
find_arch_glob_path
that returns the first path that matches the pattern/usr/lib/gcc/*/*/crtbegin.o
This doesn't happen if you specify the path with
--linux-crtbegin
, but I assume that's not the expected behaviourThe text was updated successfully, but these errors were encountered: