https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91629

            Bug ID: 91629
           Summary: gcc-ar assumes that GCC_EXEC_PREFIX is ${bindir}, but
                    it is ${libdir}/gcc
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjc at immunant dot com
  Target Milestone: ---

Created attachment 46795
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46795&action=edit
Proposed fix to handle GCC_EXEC_PATH correctly

If available, gcc-ar grabs its binary path (self) from the GCC_EXEC_PREFIX. It
then constructs a relative path difference between standard_bin_prefix and
standard_exec_prefix to make self_exec_prefix:

   self_exec_prefix = make_relative_prefix (self,
                                            standard_bin_prefix,
                                            standard_exec_prefix);

The gcc frontend sets GCC_EXEC_PREFIX to the exec_prefix, not the bin_prefix:

      gcc_exec_prefix = get_relative_prefix (decoded_options[0].arg,
                                             standard_bindir_prefix,
                                             standard_exec_prefix);
      gcc_libexec_prefix = get_relative_prefix (decoded_options[0].arg,
                                             standard_bindir_prefix,
                                             standard_libexec_prefix);
      if (gcc_exec_prefix)
        xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));


Normally this just happens to work, but if libdir and bindir were set to custom
paths in configure, then this can break.

I've attached a proposed fix, although I haven't had a chance to test it in the
environment I found this (a yocto build environment).

Reply via email to