[Question] build failed with "cannot find -lstdc++"

40 views
Skip to first unread message

Hangbin Liu

unread,
Mar 17, 2025, 1:54:41 AM3/17/25
to syzkaller
Hi,

When trying to build latest syzkaller on RHEL, I got failure like
```
Native cross-compiler is missing/broken:
/usr/bin/ld: cannot find -lstdc++: No such file or directory collect2: error: ld returned 1 exit status
```
But I have libstdc++ installed, e.g.
```
# ldconfig -p | grep libstdc++
        libstdc++.so.6 (libc6,x86-64) => /lib64/libstdc++.so.6
# echo 'int main() {}' | g++ -x c++ - -o /dev/null -lstdc++
# echo $?
0
# which gcc g++
/usr/bin/gcc
/usr/bin/g++

# go version
go version go1.24.1 linux/amd64
# g++ --version
g++ (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --without-isl --enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_64=x86-64-v3 --with-arch_32=x86-64 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 --enable-host-pie --enable-host-bind-now
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20250110 (Red Hat 14.2.1-7) (GCC)
```

Could some one help check this issue? Thanks a lot!

Here is the build log
```
# make
Makefile:31: run command via tools/syz-env for best compatibility, see:
Makefile:32: https://github.com/google/syzkaller/blob/master/docs/contributing.md#using-syz-env
go: downloading golang.org/x/sys v0.30.0
go: downloading github.com/VividCortex/gohistogram v1.0.0
go: downloading github.com/prometheus/client_golang v1.20.5
go: downloading github.com/prometheus/client_model v0.6.1
go: downloading google.golang.org/protobuf v1.36.5
go: downloading github.com/prometheus/procfs v0.15.1
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/common v0.55.0
go: downloading github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
go list -f '{{.Stale}}' ./sys/syz-sysgen | grep -q false || go install ./sys/syz-sysgen
make .descriptions
Makefile:31: run command via tools/syz-env for best compatibility, see:
Makefile:32: https://github.com/google/syzkaller/blob/master/docs/contributing.md#using-syz-env
make[1]: '.descriptions' is up to date.
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/syz-manager github.com/google/syzkaller/syz-manager
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/syz-repro github.com/google/syzkaller/tools/syz-repro
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/syz-mutate github.com/google/syzkaller/tools/syz-mutate
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/syz-prog2c github.com/google/syzkaller/tools/syz-prog2c
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/syz-db github.com/google/syzkaller/tools/syz-db
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/syz-upgrade github.com/google/syzkaller/tools/syz-upgrade
GOOS=linux GOARCH=amd64 go build "-ldflags=-s -w -X github.com/google/syzkaller/prog.GitRevision=e28266709dd2a1d1452d4a5bbf271700e10335c6 -X 'github.com/google/syzkaller/prog.gitRevisionDate=20250313-150626'" -o ./bin/linux_amd64/syz-execprog github.com/google/syzkaller/tools/syz-execprog
************************************************************************************
Executor will not be built
Native cross-compiler is missing/broken:
/usr/bin/ld: cannot find -lstdc++: No such file or directory collect2: error: ld returned 1 exit status
************************************************************************************
```

Regards
Hangbin

Taras Madan

unread,
Mar 17, 2025, 6:06:47 AM3/17/25
to Hangbin Liu, syzkaller
Hi Hangbin Liu,
testing on GCE "Red Hat Enterprise Linux 9.5 (Plow)":
```
$ ./tools/syz-env make
$ ls bin
linux_amd64  syz-db  syz-manager  syz-mutate  syz-prog2c  syz-repro  syz-sysgen  syz-upgrade
```

Build in clean environment works with syz-env.
Dev team and syzbot are using the docker based environment to address this and similar problems.

BR,
Taras


--
You received this message because you are subscribed to the Google Groups "syzkaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/syzkaller/8fdd7e55-ebb6-4872-894b-748c99c78456n%40googlegroups.com.

Hangbin Liu

unread,
Mar 17, 2025, 7:34:49 AM3/17/25
to Taras Madan, syzkaller
On Mon, Mar 17, 2025 at 11:06:06AM +0100, Taras Madan wrote:
> Hi Hangbin Liu,
> testing on GCE "Red Hat Enterprise Linux 9.5 (Plow)":
> ```
> $ ./tools/syz-env make
> $ ls bin
> linux_amd64 syz-db syz-manager syz-mutate syz-prog2c syz-repro
> syz-sysgen syz-upgrade
> ```
>
> Build in clean environment works with syz-env.
> Dev team and syzbot are using the docker based environment to address this
> and similar problems.

Hi Taras,

Thanks for your reply. I know we can use the docker env to build syz.
But my test is in internal network and unable to pull the image.

Regards
Hangbin
> > <https://groups.google.com/d/msgid/syzkaller/8fdd7e55-ebb6-4872-894b-748c99c78456n%40googlegroups.com?utm_medium=email&utm_source=footer>
> > .
> >

Hangbin Liu

unread,
Mar 17, 2025, 9:18:07 AM3/17/25
to Taras Madan, syzkaller
On Mon, Mar 17, 2025 at 11:34:47AM +0000, Hangbin Liu wrote:
> On Mon, Mar 17, 2025 at 11:06:06AM +0100, Taras Madan wrote:
> > Hi Hangbin Liu,
> > testing on GCE "Red Hat Enterprise Linux 9.5 (Plow)":
> > ```
> > $ ./tools/syz-env make
> > $ ls bin
> > linux_amd64 syz-db syz-manager syz-mutate syz-prog2c syz-repro
> > syz-sysgen syz-upgrade
> > ```
> >
> > Build in clean environment works with syz-env.
> > Dev team and syzbot are using the docker based environment to address this
> > and similar problems.

I tried syz-env on my local machine, and got warning
```
/usr/bin/ld: /tmp/ccAdktFw.o: in function `Connection::Connect(char const*, char const*)':
executor.cc:(.text._ZN10Connection7ConnectEPKcS1_[_ZN10Connection7ConnectEPKcS1_]+0x104): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
```

So, what's the glibc version on the build image? If we want to run syz-executor
on remote, it need to use the same glibc version with build system, right?

Thanks
Hangbin

Taras Madan

unread,
Mar 17, 2025, 1:07:52 PM3/17/25
to Hangbin Liu, syzkaller
>If we want to run syz-executor on remote, it need to use the same glibc version with build system, right?

That's how I read it too.

Just to double check. Do you have the headers from some package like "libstdc++-devel"?

Hangbin Liu

unread,
Mar 17, 2025, 9:56:46 PM3/17/25
to Taras Madan, syzkaller
On Mon, Mar 17, 2025 at 06:07:11PM +0100, Taras Madan wrote:
> >If we want to run syz-executor on remote, it need to use the same glibc
> version with build system, right?
>
> That's how I read it too.
>
> Just to double check. Do you have the headers from some package like
> "libstdc++-devel"?

Yes, I have libstdc++-devel installed, and still got the "cannot find -lstdc++"
error...

Thanks
Hangbin

Hangbin Liu

unread,
Mar 17, 2025, 10:25:03 PM3/17/25
to Taras Madan, syzkaller
Haha, I tried to comment the ifneq ("$(NO_CROSS_COMPILER)", "") checking
to see all the compile flags. After paste the full compile log to chatgpt,
it helps find out that there is a `-static` flag. So what I'm missing is
"libstdc++-static". After install this package, the problem solved.

Thanks
Hangbin

Taras Madan

unread,
Mar 18, 2025, 5:01:57 AM3/18/25
to Hangbin Liu, syzkaller
Thanks for sharing the final solution!

Dmitry Vyukov

unread,
Mar 18, 2025, 1:52:47 PM3/18/25
to Taras Madan, Hangbin Liu, syzkaller
The action item for us is to include the command line into the error message.
> --
> You received this message because you are subscribed to the Google Groups "syzkaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/syzkaller/CACRi13fAn8Eq%3DczPQUqumq5PPc3k%3Dx0oNV3bNu2uk1hjst2qWw%40mail.gmail.com.

Taras Madan

unread,
Mar 21, 2025, 8:33:43 AM3/21/25
to Dmitry Vyukov, Hangbin Liu, syzkaller
The error was coming from the make command.
Do you think it makes sense to catch errors in Makefile?

It may deserve some FAQ to at least help LLMs find the answer.

Dmitry Vyukov

unread,
Mar 21, 2025, 12:25:18 PM3/21/25
to Taras Madan, Hangbin Liu, syzkaller
We create this error message here:
https://github.com/google/syzkaller/blob/master/sys/targets/targets.go#L1007
We could prepend the command that was run.

Taras Madan

unread,
Mar 26, 2025, 7:31:43 AM3/26/25
to Dmitry Vyukov, Hangbin Liu, syzkaller
Reply all
Reply to author
Forward
0 new messages