Discussion:
Cannot compile using cc1.
Tejas Joshi
2018-10-06 13:07:11 UTC
Permalink
I have gcc source code, stage1-build and test directories as siblings
and I've been trying to compile test.c in test/ using:

../stage1-build/gcc/cc1 test.c

but getting error as:

In file included from test.c:1:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No
such file or directory
27 | #include <bits/libc-header-start.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

It does compile when stdio.h is not included using #include.
Source code configures and make runs without error.
Any solution or explanation?
Thanks.
Jim Wilson
2018-10-08 20:42:44 UTC
Permalink
Post by Tejas Joshi
I have gcc source code, stage1-build and test directories as siblings
../stage1-build/gcc/cc1 test.c
That isn't expected to work. You need to use the compiler driver, which
is called xgcc in the build dir, and pass an option to let it know where
the cc1 binary is. So this should instead be

../stage1-build/gcc/xgcc -B../stage1-build/gcc/ test.c

The trailing slash on the -B option path is important. If that doesn't
work, then you may have configured your gcc tree wrong. Some operating
systems require specific configure options to be used to get a working
compiler. You can see the configure options used by the default
compiler by using "/usr/bin/gcc -v". Debian/Ubuntu require
--enable-multiarch for instance, and the compiler build may not succeed
if that configure option is missing.

If you want to run cc1 directly, you may need to pass in extra default
options that the compiler driver normally passes to it. You can see
these options by passing the -v option to the gcc driver while compiling
a file. E.g. running "../stage1-build/gcc/xgcc -B../stage1-build/gcc/
-v test.c" and looking at the cc1 line will show you the options you
need to pass to cc1 to make it work.

Jim

Continue reading on narkive:
Loading...