On 11/24/25 1:56 AM, Kito Cheng wrote:
This fixes a permission error that occurs when cross-compiling with
-save-temps and a relocated toolchain, where the original build path
exists but is inaccessible.

The issue occurs when:
- Building the toolchain at /home/scratch/build/
- Installing it to another location like /home/user/rv64-toolchain/
- The /home/scratch directory exists but has insufficient permissions
   (e.g. drwx------ for /home/scratch/)

Without this fix, cc1 would report errors like:
cc1: error: /home/scratch/build/install/riscv64-unknown-elf/usr/local/include: 
Permission denied

This occurred because the GCC driver did not pass GCC_EXEC_PREFIX and
isysroot to cc1/cc1plus in the compile stage when using -save-temps.
This caused cc1/cc1plus to search for headers from the wrong (original
build) path instead of the relocated installation path.

The fix ensures cc1/cc1plus won't try to collect include paths when
-fpreprocessed is specified.  This prevents the permission error during
cross-compilation with -save-temps, as the preprocessed file already
contains all necessary headers.

gcc/c-family/ChangeLog:

        * c-opts.cc (c_common_post_options): Skip register_include_chains
        when cpp_opts->preprocessed is set.
OK.
jeff

Reply via email to