Bug 60690 - Variables used in inline assembly cause LTO link errors
Summary: Variables used in inline assembly cause LTO link errors
Status: RESOLVED DUPLICATE of bug 57703
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2014-03-27 19:55 UTC by Markus Trippelsdorf
Modified: 2014-09-06 10:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (35.34 KB, application/x-tar)
2014-03-27 19:55 UTC, Markus Trippelsdorf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2014-03-27 19:55:49 UTC
Created attachment 32467 [details]
testcase

markus@x4 tmp % cat simple_idct.i
static int __attribute__ ((used)) wm1010;
void fn1 ()
{
  __asm__(" \nmovq 0, %%mm3 \nmovq wm1010(%%rip), %%mm4 "
          "\nmovq %%mm0, 0 \nmovq %%mm0,0 \nmovq %%mm0,0  "
          " \nmovq %%mm0,0  \n2: "
          "\nmovq 0, %%mm0 \nmovq 0, %%mm1 \nmovq 0, "
          "%%mm2 \nmovq 0, %%mm3  \nmovq %%mm0, %%mm4 "
          "\npsrad $20, %%mm2 \npsrad $20, %%mm5 \nmovq %%mm6, "
          "%%mm2 \npsrad $20, %%mm5 \nmovq %%mm6, %%mm4 "
          "\npsrad $20, %%mm0 \npsrad $20, %%mm2 \npackssdw "
          "%%mm7, %%mm7 \nmovd %%mm7,0 \npackssdw %%mm0, "
          "%%mm2 \npsrad $20, %%mm5 \nmovq %%mm6, %%mm4 "
          "\nmovd %%mm6,0 \nmovd %%mm4,0 \nmovd %%mm4, %%eax  "
          "\norl %%eax, %%eax \njz 0 "
          "\nmovq 0, %%mm4 \npmaddwd %%mm0, %%mm5 "
          "\npsrad $11, %%mm7 \npsrad $11, %%mm4 "
          "\n# .p2align \n6: movq 0, %%mm1 "
          " \npsrad $20, %%mm6  \npsrad $20, %%mm2 \n9: \n"
          :);
}

markus@x4 tmp % gcc -flto -O2 -fPIC -shared dsputil_init.i simple_idct.i
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /tmp/ccQnT34K.ltrans1.ltrans.o: requires dynamic R_X86_64_PC32 reloc against 'wm1010' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status

(dsputil_init.i is just a unit to trigger LTO partitioning)

markus@x4 tmp % gcc -O2 -fPIC -shared dsputil_init.i simple_idct.i
markus@x4 tmp % gcc -flto -flto-partition=none -O2 -fPIC -shared dsputil_init.i simple_idct.i
markus@x4 tmp %
Comment 1 Markus Trippelsdorf 2014-03-27 19:59:17 UTC
May be related to PR57703.
Comment 2 Markus Trippelsdorf 2014-03-28 07:47:32 UTC
Trying to build new ffmpeg-2.2 this morning shows the same issue:
...
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans0.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'w04' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans1.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'w04' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans2.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'w04' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans3.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'w04' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans5.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'deringThreshold' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans8.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'b80' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans10.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'b80' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans11.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'deringThreshold' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans13.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'deringThreshold' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/cccBaTIP.ltrans15.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'w05' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
/var/tmp/portage/media-video/ffmpeg-2.2/work/ffmpeg-2.2/library.mak:106: recipe for target 'libpostproc/libpostproc.so.52' failed
make: *** [libpostproc/libpostproc.so.52] Error 1
make: *** Waiting for unfinished jobs....
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/ccSxjMsO.ltrans8.ltrans.o: requires dynamic
 R_X86_64_PC32 reloc against 'mmx_00ffw' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/ccSxjMsO.ltrans10.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'mmx_ff' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/ccSxjMsO.ltrans17.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'mmx_00ffw' which may overflow at runtime; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/media-video/ffmpeg-2.2/temp/ccSxjMsO.ltrans27.ltrans.o: requires dynami
c R_X86_64_PC32 reloc against 'mul15_hi' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status
/var/tmp/portage/media-video/ffmpeg-2.2/work/ffmpeg-2.2/library.mak:106: recipe for target 'libswscale/libswscale.so.2' failed

x4 ffmpeg-2.2 # grep -D skip -R -i "w04" .
./libpostproc/postprocess_template.c:            "paddw "MANGLE(w04)", %%mm0             \n\t"
./libpostproc/postprocess_template.c:            "paddw "MANGLE(w04)", %%mm1             \n\t"
./libpostproc/postprocess.c:DECLARE_ASM_CONST(8, uint64_t, w04)= 0x0004000400040004LL;

x4 ffmpeg-2.2 # grep -D skip -R -i "deringThreshold" .
./libpostproc/postprocess_template.c:        "cmpb "MANGLE(deringThreshold)", %b4    \n\t"
./libpostproc/postprocess_template.c:    if(max - min <deringThreshold) return;
./libpostproc/postprocess.c:DECLARE_ASM_CONST(8, int, deringThreshold)= 20;
./libpostproc/postprocess_altivec_template.c:    DECLARE_ALIGNED(16, uint8_t, dt)[16] = { deringThreshold };

x4 ffmpeg-2.2 # grep -D skip -R -i "mmx_00ffw" .
./libswscale/x86/yuv2rgb.c:DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw)   = 0x00ff00ff00ff00ffULL;
./libswscale/x86/yuv2rgb_template.c:    "pand     "MANGLE(mmx_00ffw)", %%mm6\n\t"    \

I guess pr48947 is also a dup.
Comment 3 Markus Trippelsdorf 2014-09-06 10:21:29 UTC
dup

*** This bug has been marked as a duplicate of bug 57703 ***