Bug 94657 - [patch] libcpp uses 'AR = ar' tool even if --build/--host are passed explicitly.
Summary: [patch] libcpp uses 'AR = ar' tool even if --build/--host are passed explicitly.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 9.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: build, patch
Depends on:
Blocks:
 
Reported: 2020-04-19 09:41 UTC by Sergei Trofimovich
Modified: 2020-05-28 23:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
libcpp-ar.patch (1.10 KB, text/plain)
2020-04-19 09:41 UTC, Sergei Trofimovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2020-04-19 09:41:34 UTC
Created attachment 48305 [details]
libcpp-ar.patch

Initially reported by Agostino Sarubbo as https://bugs.gentoo.org/718004.

There Gentoo builds gcc-9.3.0 as:
    --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu
and observes 'ar' being called by libcpp. It should be 'x86_64-pc-linux-gnu-ar' instead.

libcpp/Makefile.in hardcodes 'AR = ar' (but does not hardcode RANLIB for example:  'RANLIB = @RANLIB@'). 

A few other tools do it:

  $ git grep 'AR = ar' | cat
  gcc/ada/gcc-interface/Makefile.in:AR = ar
  intl/Makefile.in:AR = ar
  libcpp/Makefile.in:AR = ar
  libdecnumber/Makefile.in:AR = ar

but only libcpp refers 'ar' and fails build when 'ar' does not exist:

  ar cru libcpp.a charset.o directives.o directives-only.o errors.o expr.o files.o identifiers.o init.o lex.o line-map.o macro.o mkdeps.o pch.o symtab.o traditional.o
  /bin/bash: ar: command not found

Attached patch adds AR detection similar to other libraries.

But maybe it should be set in top-level Makefile?
Comment 1 Eric Gallager 2020-04-21 15:37:30 UTC
please submit the patch to the gcc-patches mailing list for review
Comment 2 Sergei Trofimovich 2020-04-22 22:06:51 UTC
Sent as https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544379.html
Comment 3 Eric Gallager 2020-04-24 22:10:44 UTC
(In reply to Sergei Trofimovich from comment #2)
> Sent as https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544379.html

thanks, adding the "patch" keyword
Comment 4 Sergei Trofimovich 2020-05-28 23:13:29 UTC
On #gcc Tobias pointed out that similar patch was merged a few days ago: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=731c4ce0e93065fb70db5faa2bd6c9c6bad56738

https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546337.html