Division clash between core and libgcc on ARM
./configure --build=x86_64-linux-gnu --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-platform=uboot
This fails with:
arm-linux-gnueabihf-gcc -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -Wcast-align -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition -o grub-script-check util/grub_script_check-grub-script-check.o grub-core/kern/emu/grub_script_check-argp_common.o grub-core/osdep/grub_script_check-init.o libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/gnulib/libgnu.a
arm-linux-gnueabihf-gcc -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -Wcast-align -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-old-style-definition -o grub-editenv util/grub_editenv-grub-editenv.o util/grub_editenv-editenv.o grub-core/osdep/grub_editenv-init.o libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/gnulib/libgnu.a
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a(_udivsi3.o): In function `__aeabi_uidiv':
(.text+0x0): multiple definition of __udivsi3' libgrubkern.a(libgrubkern_a-misc.o):misc.c:(.text+0xa3c): first defined here /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a(_udivsi3.o): In function __aeabi_uidiv':
(.text+0x0): multiple definition of `__aeabi_uidiv' libgrubkern.a(libgrubkern_a-misc.o):misc.c:(.text+0xa3c): first defined here
collect2: error: ld returned 1 exit status
I don't think we should redirect divisions when building userspace utilities; it would be simpler to just let libgcc handle them in those cases. How does this look?
* grub-core/kern/misc.c: Don't redirect divisions in the GRUB_UTIL case.
grub-core/kern/misc.c +4 -0
@@ -596,6 +596,8 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)return q; } +#ifndef GRUB_UTIL +#if defined (__arm__) grub_uint32_t
@@ -639,6 +641,8 @@ __umoddi3 (grub_uint64_t a, grub_uint64_t b)#endif +#endif /* GRUB_UTIL */ +/* Convert a long long value to a string. This function avoids 64-bit modular arithmetic or divisions. */ static char *
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
Quoted 5 lines · Colin Watson
./configure --build=x86_64-linux-gnu --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-platform=ubootThis fails with:
arm-linux-gnueabihf-gcc -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -Wcast-align -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreach
able-code -Wno-conversion -Wno-old-style-definition -o grub-script-check util/grub_script_check-grub-script-check.o grub-core/kern/emu/grub_script_check-argp_common.o grub-core/osdep/grub_script_check-init.o libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/gnulib/libgnu.a
Quoted 1 line
arm-linux-gnueabihf-gcc -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -Wcast-align -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreach
able-code -Wno-conversion -Wno-old-style-definition -o grub-editenv util/grub_editenv-grub-editenv.o util/grub_editenv-editenv.o grub-core/osdep/grub_editenv-init.o libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/gnulib/libgnu.a
Quoted 8 lines
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a(_udivsi3.o): In function `__aeabi_uidiv':
(.text+0x0): multiple definition of__udivsi3' libgrubkern.a(libgrubkern_a-misc.o):misc.c:(.text+0xa3c): first defined here /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a(_udivsi3.o): In function__aeabi_uidiv':
(.text+0x0): multiple definition of `__aeabi_uidiv' libgrubkern.a(libgrubkern_a-misc.o):misc.c:(.text+0xa3c): first defined here
collect2: error: ld returned 1 exit status
Quoted 4 lines
I don't think we should redirect divisions when building userspace utilities; it would be simpler to just let libgcc handle them in those cases. How does this look?
good
go ahead
Quoted 28 lines
*
grub-core/kern/misc.c: Don't redirect divisions in theGRUB_UTILcase.grub-core/kern/misc.c +4
-0@@ -596,6 +596,8 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)return q; } +#ifndef GRUB_UTIL +#if defined (__arm__) grub_uint32_t@@ -639,6 +641,8 @@ __umoddi3 (grub_uint64_t a, grub_uint64_t b)#endif +#endif /* GRUB_UTIL */ +/* Convert a long long value to a string. This function avoids 64-bit modular arithmetic or divisions. */ static char *Thanks,
Quoted 4 lines · Colin Watson
How does this look?
*
grub-core/kern/misc.c: Don't redirect divisions in theGRUB_UTILcase.
You also need similar adjustment to misc.h
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 2 lines · Colin Watson
*
grub-core/kern/misc.c: Don't redirect divisions in theGRUB_UTILcase.You also need similar adjustment to
misc.h
Good catch, thanks. Committed.
Signature · 1 line
Colin Watson [[email protected]]