Blub
Blub

Reputation: 13624

How do I compile a debug build of GCC?

I followed the steps on the page: https://gcc.gnu.org/wiki/DebuggingGCC#gccbuilddebug

Exact commands I did:

mkdir build
cd build
../configure --enable-stage1-languages=c --disable-multilib
make STAGE1_CXXFLAGS="-g -O0" all-stage1

I only get various xgcc or cc1 executables.

Command I need from gcc:

gcc -S test.c results in:

"xgcc: error trying to exec 'cc1': execvp: No such file or directory"

I need the gcc binary because I need to debug the -S switch and otherwise I get this error if I just use cc1: cc1: error: command line option ‘-S’ is valid for the driver but not for C

Upvotes: 3

Views: 892

Answers (1)

yugr
yugr

Reputation: 21916

GCC driver (xgcc) expects compiler proper (cc1) to be in a standard location but standard directory layout is only created during installation (make install). To run newly built but not yet installed GCC, use the infamous -B flag:

GCC_BUILD=path/to/build/dir
$GCC_BUILD/xgcc -B$GCC_BUILD -S test.c

(BTW that's how make check invokes GCC when running GCC testsuite).

Upvotes: 1

Related Questions