On 10/06/2018 06:07 AM, Tejas Joshi wrote:
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

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

Reply via email to