Build bug because of binutils 2.21

From: Steven Rostedt
Date: Sat Oct 20 2012 - 12:06:05 EST


Thomas suggested that I email you to decide if a bug I stumbled on with
binutils should be cause to blacklist version 2.21. Note, testing
against 2.22 does not show this issue.

A couple of days ago I went to test 3.6.1-rt2 and while building the
i386 kernel, the build failed. I first thought it was a bug in the -rt
patch, but then I tested vanilla 3.6.1 and that failed too. I then went
to debug this in my non -rt development repo but the build completed
without failure.

With more investigation, it seemed that one repo would cause the issue
but the other did not. A diff -r showed that the two repos were
identical (besides the .git files and my patches directory).

The build was basically:

cd good
make ARCH=i386 O=/work/build clean
make ARCH=i386 O=/work/build
cd ../bad
make ARCH=i386 O=/work/build clean
make ARCH=i386 O=/work/build
<fails build>

The error was:

lib/lib.a(decompress.o):(.rodata+0x44): undefined reference to `unlzo'

In desperation to figure out what was happening, I did the following:

cp -r bad test
cd test
make ARCH=i386 O=/work/build

And it worked! Note, I could go back and forth between the directories
and the test always worked and the 'bad' directory always failed.

Doing a make V=1, I was able to find that the problem happened during
the compile of decompress_unlzo.c. Strange that the file was identical
in both directories. I even removed the file from the good directory and
made it a softlink to the bad one, and the good directory still worked.
I even removed it again and made it a hard link and it still worked!

Finally I found that the output of the assembly from decompress_unlzo.c
was slightly different. By doing the make V=1 code by hand, I could
start with the output of the .s (by making it with the -S gcc option)
that .s created by the good directory would succeed the final link, and
the .s created by the bad directory would fail the final link.

Here's the diff between the two .s files:

--- lib/decompress_unlzo.stable-rt.git.s 2012-10-20 09:37:22.000000000 -0400
+++ lib/decompress_unlzo.stable-xt.git.s 2012-10-20 09:37:22.000000000 -0400
@@ -63,7 +63,7 @@
.type parse_header, @function
- .file 3 "/work/rt/stable-rt.git/lib/decompress_unlzo.c"
+ .file 3 "/work/rt/stable-xt.git/lib/decompress_unlzo.c"
.loc 3 55 0
@@ -3942,6 +3942,8 @@
.string "GNU C 4.6.0"
.string "acpi_disabled"
+ .string "/work/rt/stable-xt.git/lib/decompress_unlzo.c"
@@ -3996,8 +3998,6 @@
.string "long long int"
.string "NR_BOUNCE"
- .string "PCPU_FC_EMBED"
.string "ioport_resource"
@@ -4308,8 +4308,8 @@
.string "kmalloc"
.string "unlzo"
- .string "/work/rt/stable-rt.git/lib/decompress_unlzo.c"
+ .string "PCPU_FC_EMBED"
.string "x86_bios_cpu_apicid"

Note, the stable-rt.git file was the 'bad' directory and the
'stable-xt.git' file was from the good copied directory.

I tarballed all the necessary files and placed them here:

If you untar this and go into the broken directory, you will find a
'compile' file. Edit the GCC_PATH and GCC_PREFIX to point to a gcc with
2.21 binutils and you should be able to see this same bug. Note, my gcc
and my binutils were compiled from scratch, and I've been using this for
years and this is the first time I've had issues with it. I tested this
on both a Debian box and a Fedora F14 box, and they both showed the
issue (same version of gcc/binutils for both as I built them
individually for both boxes).

If you run ./compile with no arguments, it will compile, archive and
link the good .s file and should succeed. If you run ./compile with an
argument (any argument), it will compile, archive and link the bad .s
file and should give you that error message. If you run it with an
argument but also define GCC_AR_PATH and GCC_AR_PREFIX to be the path
and prefix of ar from binutils 2.22, it will then work.

It looks like there is a bug with 'ar' in binutils 2.21 that can cause
linking issues with these .s files.

As I said, Thomas suggested to ask you if this should be cause to
blacklist 2.21 as a 'reliable' toolchain for building the kernel. Makes
no difference to me. I've just finished upgrading my distcc farm to

-- Steve

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at