rebuilding glibc rpm package on armv7hl

Hi,

I try to rebuild on openSUSE 13.1 for armv7hl the glibc package, with

    rpmbuild --rebuild glibc-2.18-4.44.1.src.rpm

but it fails with :

gcc -nostdlib -nostartfiles -r -o /home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os ‘-Wl,-(’ /home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/dl-allobjs.os /home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/rtld-libc.a -lgcc ‘-Wl,-)’
-Wl,-Map,/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os.map
gcc -nostdlib -nostartfiles -shared -o /home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/ld.so.new
-Wl,-z,combreloc -Wl,-z,relro -Wl,–hash-style=both -Wl,-z,defs -Wl,-z,now
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os -Wl,–version-script=/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/ld.map
-Wl,-soname=ld-linux-armhf.so.3
-Wl,-defsym=_begin=0
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os: In function dl_main': /home/phdm/rpmbuild/BUILD/glibc-2.18/elf/rtld.c:2287: undefined reference to __libc_do_syscall’
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os: In function _dl_map_object_from_fd': /home/phdm/rpmbuild/BUILD/glibc-2.18/elf/dl-load.c:1222: undefined reference to __libc_do_syscall’
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os: In function add_dependency': /home/phdm/rpmbuild/BUILD/glibc-2.18/elf/dl-lookup.c:537: undefined reference to __libc_do_syscall’
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os: In function _dl_relocate_object': /home/phdm/rpmbuild/BUILD/glibc-2.18/elf/dl-reloc.c:307: undefined reference to __libc_do_syscall’
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os: In function _dl_fixup': /home/phdm/rpmbuild/BUILD/glibc-2.18/elf/dl-runtime.c:116: undefined reference to __libc_do_syscall’
/home/phdm/rpmbuild/BUILD/glibc-2.18/cc-base/elf/librtld.os:/home/phdm/rpmbuild/BUILD/glibc-2.18/elf/dl-runtime.c:237: more undefined references to `__libc_do_syscall’ follow
collect2: error: ld returned 1 exit status

Searching for the cause, I noticed that __libc_do_syscall is needed only for thumb mode, but some parts of glibc are compiled with the -mthumb flag for gcc, hence the need for __libc_do_syscall’, but other are compiled without, thus not providing __libc_do_syscall’.

Looking deeper I have seen that the -mthumb flag comes from %optflags in the following way :

    BuildFlags='-O2 -g -march=armv7-a -mfloat-abi=hard -mthumb -mabi=aapcs-linux -U_FORTIFY_SOURCE'

removing the ‘-mthumb’ flag, that comes directly from /usr/lib/rpm/rpmrc or /usr/lib/rpm/platform/armv7hl-linux/macros, I make the build succeed, but it does not provide a rpm package with identical binaries as in the opensuse glibc-2.18-4.44.1.armv7hl.

How should I do to be able to rebuild exactly glibc-2.18-4.44.1.armv7hl from glibc-2.18-4.44.1.src.rpm in order to incoporate in it a patch that I need ?

TIA

Then how this question is related to OBS where you post it?

How should I do to be able to rebuild exactly glibc-2.18-4.44.1.armv7hl from glibc-2.18-4.44.1.src.rpm

You should use exactly the same environment. rpmbuid is using whatever is available on your local system, which is not necessary what is used during distribution build. In particular, %optflags are defined here: Welcome - openSUSE Build Service

You should really use OBS or osc to rebuild your RPM, this will ensure you get correct environment and can then add your patch.