View previous topic :: View next topic |
Author |
Message |
gtbX Tux's lil' helper
Joined: 11 Oct 2003 Posts: 126
|
Posted: Mon Aug 15, 2022 4:52 am Post subject: Can't configure kernel anymore |
|
|
When attempting to upgrade the kernel on my sparc Ultra 5, I can no longer execute `make oldconfig` or `make menuconfig`:
Code: | # make oldconfig
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/preprocess.o
HOSTLD scripts/kconfig/conf
{ command -v gcc; } >/dev/null 2>&1 && echo "n" || echo "y": Cannot allocate memory
make[1]: *** [scripts/kconfig/Makefile:77: oldconfig] Error 1
make: *** [Makefile:616: oldconfig] Error 2
|
There's only 512MB of RAM, but 5GB of swap space available. This used to run without error up until a few weeks ago, and I can still build the kernel with `make` if I copy over my previous .config. I'm assuming some change to the toolchain caused this, since it's affecting the last kernel version I was able to configure as well as the latest one. Any ideas? |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2182
|
Posted: Mon Aug 15, 2022 9:23 am Post subject: |
|
|
It might be worth playing with make clean and it's ilk. There may be junk left around from an earlier build that's getting in the way. _________________ Greybeard |
|
Back to top |
|
|
gtbX Tux's lil' helper
Joined: 11 Oct 2003 Posts: 126
|
Posted: Mon Aug 15, 2022 4:08 pm Post subject: |
|
|
Both `make clean` and `make distclean` run ok
Code: | # make clean
# make distclean
CLEAN scripts/basic
CLEAN scripts/kconfig
|
But `make defconfig` fails with the same error as above:
Code: | # make defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
*** Default configuration is based on 'sparc64_defconfig'
{ command -v gcc; } >/dev/null 2>&1 && echo "n" || echo "y": Cannot allocate memory
make[1]: *** [scripts/kconfig/Makefile:87: defconfig] Error 1
make: *** [Makefile:616: defconfig] Error 2
|
|
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2182
|
Posted: Tue Aug 16, 2022 9:32 am Post subject: |
|
|
It seems to be running out of space when issuing "command -v gcc", which should just return /usr/bin/gcc, so this appears to be a test for the compiler's presence. Either that or "echo" is failing! Perhaps you have something weird in your PATH or LDPATH or similar that's causing "command" to recurse infinitely following symbolic links, or some other such strangeness.
What do you get if you execute the failing line in a terminal session in the same working directory? _________________ Greybeard |
|
Back to top |
|
|
gtbX Tux's lil' helper
Joined: 11 Oct 2003 Posts: 126
|
Posted: Thu Aug 18, 2022 4:24 pm Post subject: |
|
|
The command itself runs just fine:
Code: | # { command -v gcc; } >/dev/null 2>&1 && echo "n" || echo "y"
n |
Running make with V=1 shows that it appears as if the `conf` binary is failing:
Code: | # make defconfig V=1
make -f ./scripts/Makefile.build obj=scripts/basic
make -f ./scripts/Makefile.build obj=scripts/kconfig defconfig
scripts/kconfig/conf --defconfig=arch/sparc/configs/sparc64_defconfig Kconfig
{ command -v gcc; } >/dev/null 2>&1 && echo "n" || echo "y": Cannot allocate memory
make[1]: *** [scripts/kconfig/Makefile:87: defconfig] Error 1
make: *** [Makefile:616: defconfig] Error 2 |
I tracked it down to a call to popen() in that binary:
Code: | p = popen(cmd, "r");
if (!p) {
fprintf(stderr, "Unable to popen:\n"); // added by me
perror(cmd);
exit(1);
} |
but now I'm stuck. Nothing looks out of place in my PATH (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin). I'm going to try rebuilding glibc in case popen() is broken for some reason, but I think I would have bigger problems if that were the case. |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2182
|
Posted: Fri Aug 19, 2022 9:47 am Post subject: |
|
|
What was the command (cmd)? _________________ Greybeard |
|
Back to top |
|
|
gtbX Tux's lil' helper
Joined: 11 Oct 2003 Posts: 126
|
Posted: Sat Aug 20, 2022 3:33 am Post subject: |
|
|
I added some more debugging output:
Code: | errno = 0;
p = popen(cmd, "r");
if (!p) {
fprintf(stderr, "Unable to popen \'%s\': %d\n", cmd, errno);
perror(cmd);
exit(1);
} |
Output:
Code: | # make defconfig V=1
make -f ./scripts/Makefile.build obj=scripts/basic
make -f ./scripts/Makefile.build obj=scripts/kconfig defconfig
gcc -Wp,-MMD,scripts/kconfig/.preprocess.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c -o scripts/kconfig/preprocess.o scripts/kconfig/preprocess.c
gcc -o scripts/kconfig/conf scripts/kconfig/conf.o scripts/kconfig/confdata.o scripts/kconfig/expr.o scripts/kconfig/lexer.lex.o scripts/kconfig/menu.o scripts/kconfig/parser.tab.o scripts/kconfig/preprocess.o scripts/kconfig/symbol.o scripts/kconfig/util.o
scripts/kconfig/conf --defconfig=arch/sparc/configs/sparc64_defconfig Kconfig
Unable to popen '{ command -v gcc; } >/dev/null 2>&1 && echo "n" || echo "y"': 12
{ command -v gcc; } >/dev/null 2>&1 && echo "n" || echo "y": Cannot allocate memory
make[1]: *** [scripts/kconfig/Makefile:87: defconfig] Error 1
make: *** [Makefile:616: defconfig] Error 2 |
And the man page for popen explicitly notes that it does not set errno if it can't allocate memory. wtf?
I also created a small test program to popen this command and print its output, which runs as expected:
Code: | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
char buf[3] = {0};
FILE* f = popen("{ command -v gcc; } >/dev/null 2>&1 && echo \"n\" || echo \"y\"", "r");
if (!f) {
perror("oops");
exit(1);
}
fread(buf, sizeof(buf) -1, 1, f);
printf("output of command: %s", buf);
pclose(f);
return 0;
} |
Code: | $ ./popen
output of command: n |
|
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2182
|
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22752
|
Posted: Sat Aug 20, 2022 1:13 pm Post subject: |
|
|
Since this is reproducible (though not yet minimized), I suggest using strace on the make that fails and its child processes. That will tell us exactly which system call fails, and from which process, which may help us understand why the attempted test programs are not failing as expected. |
|
Back to top |
|
|
gtbX Tux's lil' helper
Joined: 11 Oct 2003 Posts: 126
|
Posted: Thu Aug 25, 2022 4:26 am Post subject: |
|
|
When running it through strace, the bug disappears
Code: | # strace -ff -o /tmp/kernel_config/conf -e trace=%process make oldconfig V=1
make -f ./scripts/Makefile.build obj=scripts/basic
make -f ./scripts/Makefile.build obj=scripts/kconfig oldconfig
scripts/kconfig/conf --oldconfig Kconfig
#
# No change to .config
# |
At least it runs now, and I can more easily change my configuration. The logs in /tmp/kernel_config are of no help, since naturally, they trace a successful run.
I just noticed a warning produced from my now-building kernel about a missing clone3 syscall:
Code: | CALL scripts/checksyscalls.sh
<stdin>:1517:2: warning: #warning syscall clone3 not implemented [-Wcpp] |
Might that be part of the issue? When I tried rebuilding glibc, I disabled that USE flag to see if it would help at all (it didn't). Idk if that message refers to the currently running kernel, libc, or the building kernel. |
|
Back to top |
|
|
|