Error During Compilation of GNU C Library (glibc) - linux

I'm not experienced with system administration, nor the technical details of compiling C-based programs, so bear with me if I say something inaccurate.
Basically, I'm using a computing cluster that has a relatively old OS (Red Hat Enterprise Linux 4.3, from ~2006), for which I have no root access. I recurrently run into issues when compiling various programs. One common cause I can see is outdated libraries, notably the C library. I decided to compile a recent version of glibc, thinking that linking to this new C library would solve many of my problems (is this sound?). That lead me down a rabbit hole of installing a more recent version of gcc and its dependencies (including modern Linux kernel headers).
In any case, I believe I have a working version of gcc. Now, when I attempt to compile glibc using this new gcc, I run into an error during the compilation, as follows (these are the last few lines):
[...]
make[2]: Leaving directory `/home/bgrande/software/apollo/src/glibc-2.19/login'
make subdir=elf -C elf ..=../ subdir_lib
make[2]: Entering directory `/home/bgrande/software/apollo/src/glibc-2.19/elf'
Makefile:896: *** target `.dyn' leaves prerequisite pattern empty. Stop.
make[2]: Leaving directory `/home/bgrande/software/apollo/src/glibc-2.19/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/home/bgrande/software/apollo/src/glibc-2.19'
make: *** [all] Error 2
I'm at a loss at understanding what
Makefile:896: *** target `.dyn' leaves prerequisite pattern empty. Stop.
means and, more importantly, what could possibly solve this. Google and Stack Overflow searches haven't turned anything up.
I'm aware that this is probably due to something relative to my system environment, although I wouldn't know what exactly. If ever I can provide additional information that could help, let me know. I would appreciate a solution, but also a rationale for the solution and perhaps a way of interpreting the error for future reference. Thank you!
Update: Installing a more recent version of Make (make-4.0) as per #andrewdotn's suggestion did resolve the error, but another one crops up later in the compilation (see below). Any ideas?
[...]
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(ns_print.os): In function `__GI_ns_sprintrrf':
/home/bgrande/software/apollo/src/glibc-2.19/resolv/ns_print.c:99: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/src/glibc-2.19/resolv/ns_print.c:728: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(gethnamaddr.os): In function `getanswer':
/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:180: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:483: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(gethnamaddr.os): In function `__GI_res_gethostbyname2':
/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:510: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(gethnamaddr.os):/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:636: more undefined references to `__stack_chk_guard' follow
collect2: error: ld returned 1 exit status
../Makerules:438: recipe for target '/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv.so' failed
make[2]: *** [/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv.so] Error 1
make[2]: Leaving directory '/home/bgrande/software/apollo/src/glibc-2.19/resolv'
Makefile:213: recipe for target 'resolv/others' failed
make[1]: *** [resolv/others] Error 2
make[1]: Leaving directory '/home/bgrande/software/apollo/src/glibc-2.19'
make: *** [all] Error 2

That sounds like it’s caused by an old version of Make. RHEL 4.3 uses Make 3.80 from 2002. Try downloading Make 3.82 or 4.0 from ftp.gnu.org, building it in your home directory, and using that to drive the compile.

Related

Problems building driver on Linux kernel 5.8.x

I'm working with a Linux driver that is building on v5.7.x kernels but not on the latest v5.8.x releases.
To summarise, most of the driver is pre-built and the kernel interface is built on the target. This involves a make -f Kbuild command.
Having checked all of the relevant kernel interface files for any changes that would affect us, normally the driver would just build as usual on a new kernel. However, this time we get the following error:
make[2]: *** [scripts/Makefile.modpost:111: /path/to/source/Module.symvers] Error 1
make[1]: *** [Makefile:1669: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.8.0-1.el8.elrepo.x86_64'
make: *** [Kbuild:26: default] Error 2
This is from CentOS 8.1, but the same error has been seen on Ubuntu 20.04.
I am no expert on this so interpreting these errors is a bit difficult. I have tried building with the KBUILD_VERBOSE flag and it doesn't really provide any useful information, other than the build succeeding until this point.
On previous kernels the Module.symvers file would be created but empty. On 5.8 this file is not created at all presumably due to this error. As a result, the .ko file is not created.
Finally, if we drop in the source files rather than the pre-built .o files the build does succeed. These .o files are built with a very old version of GCC (4.4.7) but we have also tried building with a much newer version (8.3.1), the same version as the target machine.
I would appreciate suggestions for things to check. Let me know if any other details would help.
Edit:
I ran make on Makefile.modpost manually and got the following output:
sudo make -f ./scripts/Makefile.modpost
WARNING: Symbol version dump "vmlinux.symvers" is missing.
Modules may not have dependencies or modversions.
make -f /scripts/Makefile.modfinal
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-050800-generic'
make[1]: /scripts/Makefile.modfinal: No such file or directory
make[1]: *** No rule to make target '/scripts/Makefile.modfinal'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-050800-generic'
make: *** [scripts/Makefile.modpost:117: __modpost] Error 2
I am answering my own question in case it helps anyone else with this problem. Although it has never been an issue in the past, we've always had a warning that the corresponding .o.cmd file was not present for our .o_shipped files. This appears to be important in kernel 5.8 onwards and my fix was to add a touch command to the Kbuild file (i.e. "touch .driver.o.cmd"). This does not remove the warning but it allows the driver to build as normal.

Fail to build y86-64 simulator from sources

I am attempting to compile a simulator for Y86-64 code on Linux.I have already rewritten the makefile but it turned out like below.It said "undefined reference for 'matherr'".(Looks like it connects with gcc when linking)
(cd pipe; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5 ")
make[1]: 进入目录“/home/gongchen/桌面/ICS/archlab-handout/sim/pipe”
# Building the pipe-std.hcl version of PIPE
../misc/hcl2c -n pipe-std.hcl < pipe-std.hcl > pipe-std.c
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
../misc/isa.c -L/usr/lib/ -ltk8.5 -ltcl8.5 -lm
/tmp/cchKTZy7.o:(.data.rel+0x0):对‘matherr’未定义的引用
collect2: error: ld returned 1 exit status
Makefile:42: recipe for target 'psim' failed
make[1]: *** [psim] Error 1
make[1]: 离开目录“/home/gongchen/桌面/ICS/archlab-handout/sim/pipe”
Makefile:28: recipe for target 'all' failed
make: *** [all] Error 2
gcc -Wall -O2 -I/usr/include/tcl8.5 -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
../misc/isa.c -L/usr/lib/ -ltk8.5 -ltcl8.5 -lm
/tmp/cchKTZy7.o:(.data.rel+0x0):对‘matherr’未定义的引用
You are linking and getting an undefined reference error to matherr.
It looks like matherr is part of SVID math library. According to the matherr(3) man page the symbol is no longer present in Glibc 2.27 or above.
DESCRIPTION
Note: the mechanism described in this page is no longer supported by
glibc. Before glibc 2.27, it had been marked as obsolete. Since
glibc 2.27, the mechanism has been removed altogether. New
applications should use the techniques described in math_error(7) and
fenv(3). This page documents the matherr() mechanism as an aid for
maintaining and porting older applications.
The math_error(7) man page says that you should do the following to check for errors:
set errno to zero
call feclearexcept(FE_ALL_EXCEPT);
After the math calculation completes you should check the following for non-zero value to indicate error:
errno
fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW);
Since you are a guy or gal trying to use the program (and not a maintainer) I suggest two courses of actions. The strategy is to use a distro where things just work, and punt to the Y86 maintainer to fix it.
First, use a different, older distro that provides Glibc 2.26 or early. Something like Debian 8 (Glibc 2.19) or Fedora 25 (Glibc 2.24) should do just fine.
Second, file a bug report against Y86 project. The Y86 maintainers need to fix the problem, not students trying to learn the class material.
My classmates have a way to solve this problem: comment the code related to matherr, like the code in the picture. And the GUI mode works. 好厉害!

How do I find the actual GCC error in compiler output?

I'm trying to compile some old software from source on debian-based linux.
The build failed:
make[2]: Leaving directory '/home/owner/kallistios/utils/dc-chain/build-gcc-sh-elf-4.7.3'
Makefile:871: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/owner/kallistios/utils/dc-chain/build-gcc-sh-elf-4.7.3'
Makefile:201: recipe for target 'build-sh4-gcc-pass2' failed
make: *** [build-sh4-gcc-pass2] Error 1
owner#ubuntu:~/kallistios/utils/dc-chain$
But it doesn't say what the actual error is or how I can find it in the output.
If I don't know what the problem is obviously I can't fix it.
This is the full output:
http://pasted.co/cff68fa2
The first thing to do if you're having problems deciphering error output is to NOT run the build in parallel (don't use the -j flag). Also you should NOT use the keep-going (-k) flag. If you don't use -j or -k then make will run one recipe at a time and fail as soon as a recipe fails. So, whenever you get an error the last command that was printed is the one that failed.
Also if you want to use -j and you're using a new-enough version of GNU make (4.0 or above) you can add the -Otarget option which will collect all the output from a given target and print it atomically at the end of the recipe, rather than interweaving output from different recipes together.
In your situation it appears as though one of the configure operations failed. It's not easy to tell exactly why because of the parallel build output. This may or may not be related:
kos is an unknown thread package
...
Makefile:3810: recipe for target 'configure-gcc' failed
make[2]: *** [configure-gcc] Error 1
You are trying to compile the Sega Dreamcast toolchain which I know very well, using the dc-chain utility inside KallistiOS (often shortened to KOS).
The key error message here is kos is an unknown thread package. It means that you don't have applied the KOS patches before compiling your sh-elf cross-compiler.
To solve this issue, you just have to enter the make patch command before running everything else. Please note, if you just enter the make command, it will already apply the patches.
To finish this answer, you may check the KallistiOS Nitro repository, as this repo is handling the official KOS plus a lot of community patches, including some very interesting things about the dc-chain utility, like complete documentation.

Linux kernel 'make rpm-pkg' throws error

I am trying to create a custom kernel rpm. So I made use of "make rpm-pkg".
Everything was going fine until it hit this error.
..
..
INSTALL sound/usb/line6/snd-usb-toneport.ko
INSTALL sound/usb/line6/snd-usb-variax.ko
INSTALL sound/usb/misc/snd-ua101.ko
INSTALL sound/usb/snd-usb-audio.ko
INSTALL sound/usb/snd-usbmidi-lib.ko
scripts/Makefile.fwinst:43: *** mixed implicit and static pattern rules. Stop.
make[2]: *** [_modinst_post] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.jJi4sq (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.p88MqU (%install)
make[1]: *** [rpm-pkg] Error 1
make: *** [rpm-pkg] Error 2
I understand there is something wrong with Makefile declarations, but also wondering if anyone has hit this issue.
If you are using make version 3.81 or 3.82 then this is likely the known make "bug" discussed here.
Specifically a change to what make believes is a meaningful set of targets to specify in a single list changed in an incompatible way and the kernel had been using a set of targets that became invalid.
The fix, after some back and forth between the GNU Make maintainer and some concerned other developers, was to convert the fatal error into a warning (at least temporarily).
I was able to fix this. Apparently its an issue with the UTS_MACHINE not being right for arm64. It should be aarch64 so that the packaging scripts use it right. there's also small tweak in the script that generates the rpm spec file.
So 'make' is not an issue in this case.

Error when using Mingw on Windows

I am completely new to this. I have a C program which compiles fine and runs fine on linux. I want to run the same code on a Windows machine so I am using the cross compiler Mingw. However every time i try and build the project i get this error:
14:51:21 **** Incremental Build of configuration Default for project zbar-0.10 ****
make all
make all-am
make[1]: Entering directory `D:/zbar-0.10'
! was unexpected at this time.
make[1]: *** [include/config.h] Error 255
make[1]: Leaving directory `D:/zbar-0.10'
make: *** [all] Error 2
14:51:26 Build Finished (took 4s.493ms)
I have googled around and still do not understand why i am getting it. Any advice?
Build with exact versions of tools as specified in: http://sourceforge.net/apps/mediawiki/zbar/index.php?title=HOWTO:_Compile_with_MinGW_in_Windows
The code is old and the make will break with newer versions.

Resources