Created attachment 44937 [details] WIP patch/work around Commit r263988 (for PR86517 "relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object with LTO") makes a lot of (or even all?) Intel MIC offloading test cases fail to compile: [...]/ld: /tmp/ccCCZyfF.o: relocation R_X86_64_32S against `[...]' can not be used when making a shared object; recompile with -fPIC /tmp/ccCCZyfF.o: error adding symbols: Bad value mkoffload-intelmic: fatal error: [...] I have not yet analyzed what's actually going wrong. Before spending more time on this, I first wanted to make sure that's still useful -- given that in the past two months apparently nobody but me has run into this (or didn't bother to report it), and I thus wonder whether anyone but me is still testing Intel MIC (emulated) offloading? No idea yet if the attached patch/hack is correct in any way, but it at least restores Intel MIC (emulated) offloading compilation.
Do you have a testcase?
(In reply to H.J. Lu from comment #1) > Do you have a testcase? Thought that would be obvious from the report. Configure GCC for Intel MIC (emulated) offloading, then run the libgomp testsuite.
(In reply to Thomas Schwinge from comment #2) > (In reply to H.J. Lu from comment #1) > > Do you have a testcase? > > Thought that would be obvious from the report. Configure GCC for Intel MIC > (emulated) offloading, then run the libgomp testsuite. Please provide your GCC configure options.
See https://gcc.gnu.org/wiki/Offloading
[hjl@gnu-cfl-1 pr87833]$ cat x.i void open_fd(char *); void init_ioctl_ctl() { open_fd(""); } void get_ioctl_ops() {} [hjl@gnu-cfl-1 pr87833]$ cat y.i void get_ioctl_ops(); void a() { get_ioctl_ops(); } [hjl@gnu-cfl-1 pr87833]$ make /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -O2 -fPIC -c y.i /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -O2 -fPIC -c x.i /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -o x.so y.o x.o -shared -fPIC -fno-pie [hjl@gnu-cfl-1 pr87833]$ make clean rm -f *.o *.s foo bar *.[cCi].* x *.ii.* *.a [hjl@gnu-cfl-1 pr87833]$ make LTO=1 /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -O2 -flto -fPIC -c y.i /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -O2 -flto -fPIC -c x.i /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -o x.so y.o x.o -shared -fPIC -fno-pie /usr/local/bin/ld: /tmp/x.so.LWF6nG.ltrans0.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/local/bin/ld: final link failed: nonrepresentable section on output collect2: error: ld returned 1 exit status make: *** [Makefile:21: x.so] Error 1 [hjl@gnu-cfl-1 pr87833]$ -fPIC -fno-pie should turn off PIE/pie, not PIC/pic.
A patch is posted at https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00084.html
On gcc-8-branch, as of r267610 (for PR86517, PR88185), this is now broken, too. I'll commit H.J.'s patch.
Author: tschwinge Date: Mon Nov 11 08:38:28 2019 New Revision: 278041 URL: https://gcc.gnu.org/viewcvs?rev=278041&root=gcc&view=rev Log: [PR87833] x86: Put -fPIC and -shared the last to create offload image On x86, since -fPIC and -shared should be used to create offload image, we put them the last to properly create offload image. 2019-11-11 H.J. Lu <hjl.tools@gmail.com> PR target/87833 * config/i386/intelmic-mkoffload.c (prepare_target_image): Put -fPIC and -shared the last to create offload image. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/intelmic-mkoffload.c
Author: tschwinge Date: Mon Nov 11 08:39:10 2019 New Revision: 278042 URL: https://gcc.gnu.org/viewcvs?rev=278042&root=gcc&view=rev Log: [PR87833] x86: Put -fPIC and -shared the last to create offload image On x86, since -fPIC and -shared should be used to create offload image, we put them the last to properly create offload image. 2019-11-11 H.J. Lu <hjl.tools@gmail.com> PR target/87833 * config/i386/intelmic-mkoffload.c (prepare_target_image): Put -fPIC and -shared the last to create offload image. Backport from trunk r278041. Modified: branches/gcc-9-branch/gcc/ChangeLog branches/gcc-9-branch/gcc/config/i386/intelmic-mkoffload.c
Author: tschwinge Date: Mon Nov 11 08:39:32 2019 New Revision: 278043 URL: https://gcc.gnu.org/viewcvs?rev=278043&root=gcc&view=rev Log: [PR87833] x86: Put -fPIC and -shared the last to create offload image On x86, since -fPIC and -shared should be used to create offload image, we put them the last to properly create offload image. 2019-11-11 H.J. Lu <hjl.tools@gmail.com> PR target/87833 * config/i386/intelmic-mkoffload.c (prepare_target_image): Put -fPIC and -shared the last to create offload image. Backport from trunk r278041. Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/config/i386/intelmic-mkoffload.c
.