Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 812329 - sys-fs/udev-249-r2 fails to build on x86 musl
Summary: sys-fs/udev-249-r2 fails to build on x86 musl
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo musl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-09 19:38 UTC by Andreas K. Hüttel
Modified: 2021-09-25 17:50 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas K. Hüttel archtester gentoo-dev 2021-09-09 19:38:23 UTC
sys-fs/udev fails to build on x86 musl (found during stage3 build)

From the log:


FAILED: src/udev/v4l_id 
i686-gentoo-linux-musl-gcc  -o src/udev/v4l_id src/udev/v4l_id.p/v4l_id_v4l_id.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -fstack-protector -Wl,--gc-sections -O2 -march=i68>
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `create_log_socket':
log.c:(.text.create_log_socket+0x10e): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `write_to_journal':
log.c:(.text.write_to_journal+0x19c): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `log_open':
log.c:(.text.log_open+0x420): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `write_to_console.constprop.0.isra.0':
log.c:(.text.write_to_console.constprop.0.isra.0+0x3e4): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `log_dispatch_internal':
log.c:(.text.log_dispatch_internal+0x732): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/udev/v4l_id.p/v4l_id_v4l_id.c.o:v4l_id.c:(.text.startup.main+0x236): more undefined references to `__s>
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/udev/v4l_id: hidden symbol `__stack_chk_fail_local' isn't defined
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
[389/395] i686-gentoo-linux-musl-gcc  -o src/udev/mtd_probe src/udev/mtd_probe.p/mtd_probe_mtd_probe.c.o src/udev/mtd_probe.p/mtd_probe_probe_smartmedia.c.o -Wl,--as-needed -Wl,--no-undefined >
FAILED: src/udev/mtd_probe 
i686-gentoo-linux-musl-gcc  -o src/udev/mtd_probe src/udev/mtd_probe.p/mtd_probe_mtd_probe.c.o src/udev/mtd_probe.p/mtd_probe_probe_smartmedia.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-z,rel>
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `create_log_socket':
log.c:(.text.create_log_socket+0x10e): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `write_to_journal':
log.c:(.text.write_to_journal+0x19c): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `log_open':
log.c:(.text.log_open+0x420): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `write_to_console.constprop.0.isra.0':
log.c:(.text.write_to_console.constprop.0.isra.0+0x3e4): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o): in function `log_dispatch_internal':
log.c:(.text.log_dispatch_internal+0x732): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/basic/libbasic.a(log.c.o):log.c:(.text.log_internalv+0x156): more undefined references to `__stack_chk>
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: src/udev/mtd_probe: hidden symbol `__stack_chk_fail_local' isn't defined
/usr/lib/gcc/i686-gentoo-linux-musl/10.3.0/../../../../i686-gentoo-linux-musl/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

... and more ...
Comment 1 Jory A. Pratt gentoo-dev 2021-09-09 21:35:05 UTC
This will require x86 linking to libssp_nonshared.a or fixing gcc to properly support using libssp_nonshared.a patch can be provided if you want to test on gcc and then try to emerge udev again.
Comment 2 Anthony Basile gentoo-dev 2021-09-11 17:19:24 UTC
(In reply to Jory A. Pratt from comment #1)
> This will require x86 linking to libssp_nonshared.a or fixing gcc to
> properly support using libssp_nonshared.a patch can be provided if you want
> to test on gcc and then try to emerge udev again.

Not necessarily.  You can add CFLAGS="--no-stack-protector" to avoid the call to __stack_chk_fail_local()
Comment 3 Mike Gilbert gentoo-dev 2021-09-11 17:46:02 UTC
Ideally, this test should detect that -fstack-protector does not work properly.

https://github.com/systemd/systemd/blob/v249/meson.build#L408

However, the test program meson generates is not complex enough to cause the necessary link failure.

> int main(void) { return 0; }

blueness came up with the following minimal test program that exhibits the failure:

> void f(char *p) { 
>         return ;
> }
> int main(){ 
>         char a[10];
>         f(a) ;
>         return 0 ;
> }
Comment 4 Anthony Basile gentoo-dev 2021-09-11 20:47:32 UTC
(In reply to Mike Gilbert from comment #3)
> Ideally, this test should detect that -fstack-protector does not work
> properly.
> 
> https://github.com/systemd/systemd/blob/v249/meson.build#L408
> 
> However, the test program meson generates is not complex enough to cause the
> necessary link failure.
> 
> > int main(void) { return 0; }
> 
> blueness came up with the following minimal test program that exhibits the
> failure:
> 
> > void f(char *p) { 
> >         return ;
> > }
> > int main(){ 
> >         char a[10];
> >         f(a) ;
> >         return 0 ;
> > }

Actually I have an even smaller program:

int main(){ 
	char a[4];
	return 0 ;
}

which fails for `gcc -fstack-protector -o test test.c`.  If you decrease the array size below 4, it no longer fails for stack-protector, but does for stack-protector-strong all the way down to 1.
Comment 5 Jory A. Pratt gentoo-dev 2021-09-11 21:26:21 UTC
(In reply to Anthony Basile from comment #2)
> (In reply to Jory A. Pratt from comment #1)
> > This will require x86 linking to libssp_nonshared.a or fixing gcc to
> > properly support using libssp_nonshared.a patch can be provided if you want
> > to test on gcc and then try to emerge udev again.
> 
> Not necessarily.  You can add CFLAGS="--no-stack-protector" to avoid the
> call to __stack_chk_fail_local()

Well this would work, be easier to support stack_chk_fail_local via the overlay with ssp patch for gcc for x86 users. I am unable to chroot to an x86 setup to do my testing at moment I will try to make it happen before weekend end.
Comment 6 Jory A. Pratt gentoo-dev 2021-09-25 17:50:48 UTC
Gcc not links libssp_nonshared.a for all archs.