Bug 2106133
| Summary: | Confusing message when using -r attempting to create a relocatable object from multiple objects | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Paulo Andrade <pandrade> |
| Component: | gcc | Assignee: | Marek Polacek <mpolacek> |
| gcc sub component: | system-version | QA Contact: | qe-baseos-tools-bugs |
| Status: | CLOSED NOTABUG | Docs Contact: | |
| Severity: | medium | ||
| Priority: | unspecified | CC: | ahajkova, fweimer, jakub, mpolacek, ohudlick, sipoyare |
| Version: | 8.6 | ||
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2022-07-13 17:50:00 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
It seems to me that the problem is rather that in older GCCs -r didn't imply -nostdlib. So I think the workaround/solution is to use -r -nostdlib. |
In C it would be like: $ gcc hello.c -o hello.o -c hello.c: In function ‘main’: hello.c:3:1: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default] printf("hello world!\n"); ^ $ file hello.o hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped $ gcc hello.o -r /usr/bin/ld: cannot find -lgcc_s /usr/bin/ld: cannot find -lc /usr/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status But the actual problem user experienced was: $ gfortran -v -r -o BIG.o a.o b.o c.o ... Driving: gfortran -v -r -o BIG.o a.o b.o c.o -l gfortran -l m -shared-libgcc ... OLLECT_GCC_OPTIONS='-v' '-r' '-o' 'BIG.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-redhat-linux/8/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/8/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper -plugin-opt=-fresolution=/tmp/ccEsZ4ao.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o BIG.o -r /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/8/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/8 -L/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/8/../../.. a.o b.o c.o ... -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/8/crtend.o /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crtn.o /usr/bin/ld: cannot find -lgfortran /usr/bin/ld: cannot find -lm /usr/bin/ld: cannot find -lgcc_s /usr/bin/ld: cannot find -lquadmath /usr/bin/ld: cannot find -lm /usr/bin/ld: cannot find -lgcc_s /usr/bin/ld: cannot find -lc /usr/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status The driver should print some error message when '-r' is used like this. As well as some explanation about the issue. The linker is attempting to statically link.