Bug 104973 - GCC 11.2.1 build failure with Go support (mv: cannot stat 'cpugen.o': No such file or directory)
Summary: GCC 11.2.1 build failure with Go support (mv: cannot stat 'cpugen.o': No such...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: go (show other bugs)
Version: 11.2.1
: P3 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords: build
Depends on: 122794
Blocks: 84402
  Show dependency treegraph
 
Reported: 2022-03-18 02:05 UTC by Sam James
Modified: 2025-12-17 04:54 UTC (History)
4 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
build.log.xz (248.32 KB, application/x-xz)
2022-03-18 02:05 UTC, Sam James
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2022-03-18 02:05:43 UTC
Created attachment 52648 [details]
build.log.xz

Initially reported downstream in Gentoo at https://bugs.gentoo.org/828439.

```
/bin/bash ../libtool  --tag=CXX   --mode=compile /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc/xgcc -shared-libgcc -B/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc -nostdinc++ -L/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/x86_64-pc-linux-gnu/32/libstdc++-v3/src -L/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127>
libtool: compile: mv -f "cpugen.o" "internal/.libs/cpu.o"
mv: cannot stat 'cpugen.o': No such file or directory
make[4]: *** [Makefile:3001: internal/cpu.lo] Error 1
make[4]: Leaving directory '/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/x86_64-pc-linux-gnu/libgo'
make[3]: *** [Makefile:2327: all-recursive] Error 1
libtool: compile:  /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc/xgcc -shared-libgcc -B/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc -nostdinc++ -L/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/x86_64-pc-linux-gnu/32/libstdc++-v3/src -L/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/x86_64-pc-linux-gn>
make[3]: Leaving directory '/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/x86_64-pc-linux-gnu/libgo'
make[2]: *** [Makefile:1198: all] Error 2
make[2]: Leaving directory '/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/x86_64-pc-linux-gnu/libgo'
make[1]: *** [Makefile:21736: all-target-libgo] Error 2
make[1]: *** Waiting for unfinished jobs....
```

Reported for both the 11.2.1 snapshots from 20211127 and 20220115. I don't see any relevant changes in git since those.

I've attached the full (compressed) build.log which Dennis uploaded in the original Gentoo bug.
Comment 1 Drea Pinski 2022-03-18 02:33:32 UTC
Can you attach what is inside cpugen.go?
Comment 2 Ian Lance Taylor 2022-03-18 04:46:16 UTC
Your build log shows a line like this:

libtool: compile:  /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc/gccgo -B/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=internal/cpu /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/gcc-11-20211127/libgo/go/internal/cpu/cpu.go /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/gcc-11-20211127/libgo/go/internal/cpu/cpu_amd64.go /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/gcc-11-20211127/libgo/go/internal/cpu/cpu_x86.go cpugen.go 

My build log shows a line like this:

libtool: compile:  /home/iant/gcc/gcc-11-objdir/./gcc/gccgo -B/home/iant/gcc/gcc-11-objdir/./gcc/ -B/home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/bin/ -B/home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/lib/ -isystem /home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/include -isystem /home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/sys-include -fchecking=1 -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=internal/cpu ../../../gcc-11-branch/libgo/go/internal/cpu/cpu.go ../../../gcc-11-branch/libgo/go/internal/cpu/cpu_amd64.go ../../../gcc-11-branch/libgo/go/internal/cpu/cpu_x86.go cpugen.go  -fPIC -o internal/.libs/cpu.o

Note that my line has a -o ption at the end but yours does not.

I think that is the root of the problem.

Earlier your log has this:

/usr/sbin/mkdir -p internal; files=`echo /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/gcc-11-20211127/libgo/go/internal/cpu/cpu.go /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/gcc-11-20211127/libgo/go/internal/cpu/cpu_amd64.go /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/gcc-11-20211127/libgo/go/internal/cpu/cpu_x86.go cpugen.go | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; /bin/bash ./libtool --tag GO --mode=compile /var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc/gccgo -B/var/tmp/portage/sys-devel/gcc-11.2.1_p20211127/work/build/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include     -minline-all-stringops  -O2 -g -I . -c -fgo-pkgpath=`echo internal/cpu.lo | sed -e 's/.lo$//'`  -o internal/cpu.lo $files

My log has this:

/bin/mkdir -p internal; files=`echo ../../../gcc-11-branch/libgo/go/internal/cpu/cpu.go ../../../gcc-11-branch/libgo/go/internal/cpu/cpu_amd64.go ../../../gcc-11-branch/libgo/go/internal/cpu/cpu_x86.go cpugen.go | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; /bin/sh ./libtool --tag GO --mode=compile /home/iant/gcc/gcc-11-objdir/./gcc/gccgo -B/home/iant/gcc/gcc-11-objdir/./gcc/ -B/home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/bin/ -B/home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/lib/ -isystem /home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/include -isystem /home/iant/gcc/gcc-11-install/x86_64-pc-linux-gnu/sys-include   -fchecking=1  -minline-all-stringops  -O2 -g -I . -c -fgo-pkgpath=`echo internal/cpu.lo | sed -e 's/.lo$//'`  -o internal/cpu.lo $files

Here the -o option is present in both cases.

So why does the -o option disappear?  Could this be somehow due to the patches being applied at the start of your build log?
Comment 3 PaX Team 2022-03-18 09:28:36 UTC
(In reply to Andrew Pinski from comment #1)
> Can you attach what is inside cpugen.go?

i'm one of the original bug reproducers, this is what i get here:

------------------------------------------------------------
work # find . -name  cpugen.go -ls
 29921892      4 -rw-r--r--   1 root     root           74 Mar 18 10:13 ./build/x86_64-pc-linux-gnu/libgo/cpugen.go
 29922436      4 -rw-r--r--   1 root     root           74 Mar 18 10:13 ./build/x86_64-pc-linux-gnu/32/libgo/cpugen.go
work # cat ./build/x86_64-pc-linux-gnu/libgo/cpugen.go
package cpu
const CacheLinePadSize = 64
const FunctionDescriptors = false
work # cat ./build/x86_64-pc-linux-gnu/32/libgo/cpugen.go
package cpu
const CacheLinePadSize = 64
const FunctionDescriptors = false
------------------------------------------------------------

the relevant build log:

libtool: compile:  /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/build/./gcc/gccgo -B/tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/build/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include -fchecking=1 -minline-all-stringops -O2 -g -m32 -I . -c -fgo-pkgpath=golang.org/x/sys/cpu /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/byteorder.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu_gccgo_x86.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu_linux_noinit.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu_x86.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/hwcap_linux.go gcpugen.go  -fPIC -o golang.org/x/sys/.libs/cpu.o

libtool: compile:  /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/build/./gcc/gccgo -B/tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/build/./gcc/ -B/usr/x86_64-pc-linux-gnu/bin/ -B/usr/x86_64-pc-linux-gnu/lib/ -isystem /usr/x86_64-pc-linux-gnu/include -isystem /usr/x86_64-pc-linux-gnu/sys-include -fchecking=1 -minline-all-stringops -O2 -g -m32 -I . -c -fgo-pkgpath=golang.org/x/sys/cpu /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/byteorder.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu_gccgo_x86.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu_linux_noinit.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/cpu_x86.go /tmp/portage/sys-devel/gcc-11.2.1_p20220115/work/gcc-11-20220115/libgo/go/golang.org/x/sys/cpu/hwcap_linux
.go gcpugen.go -o golang.org/x/sys/cpu.o >/dev/null 2>&1

note that there's a -o output specified but it's for the 'wrong' file name. i've got these cpu.o files:

work # find . -name  cpu.o -ls
 29922270     60 -rw-r--r--   1 root     root        58160 Mar 18 10:13 ./build/x86_64-pc-linux-gnu/libgo/cpu.o
 29923192     44 -rw-r--r--   1 root     root        41656 Mar 18 10:13 ./build/x86_64-pc-linux-gnu/32/libgo/internal/cpu.o
 29922867     44 -rw-r--r--   1 root     root        43384 Mar 18 10:13 ./build/x86_64-pc-linux-gnu/32/libgo/internal/.libs/cpu.o
 29927256     92 -rw-r--r--   1 root     root        92688 Mar 18 10:15 ./build/x86_64-pc-linux-gnu/32/libgo/golang.org/x/sys/cpu.o
 29927254     96 -rw-r--r--   1 root     root        95608 Mar 18 10:15 ./build/x86_64-pc-linux-gnu/32/libgo/golang.org/x/sys/.libs/cpu.o

would you like me to upload anything of the above or any other build files?
Comment 4 Ian Lance Taylor 2022-03-18 18:32:58 UTC
The golang.org/x/sys/cpu.o is a different object file.  That one uses gcpugen.go, not cpugen.go.  The original reporter is not reporting any problems involving gcpugen.go.  The cpugen.go (not gcpugen.go) file is an input for internal/cpu.o.
Comment 5 Sam James 2022-03-19 17:43:24 UTC
I'm forwarding a report from downstream which two people have commented in:
1. Dennis, the original reporter;
2. PaX Team, who commented too.

They're likely the same issue or related. I can't reproduce it myself yet, but I've tried repeatedly.