Skip to content

Commit

Permalink
Bug 1522609 - Pass HOST_CC/HOST_CXX/HOST_CFLAGS/HOST_CXXFLAGS down to…
Browse files Browse the repository at this point in the history
… cargo. r=ted

While this isn't related to the bug, since we're going to touch the
cargo compiler flags, we might as well do this too.

It wasn't previously reliable to pass those flags down because what
cargo uses as target for build scripts and procedural macros is
determined by the rust host, which was not necessarily the same as the
build system host. But as of bug 1523143, they are always the same.

Differential Revision: https://phabricator.services.mozilla.com/D18280

--HG--
extra : moz-landing-system : lando
  • Loading branch information
glandium committed Feb 5, 2019
1 parent 51a9efc commit 401ecc4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions config/makefiles/rust.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,21 @@ ifndef FUZZING_INTERFACES
# which will muck things up.
# * Don't do this for GCC code coverage builds because the way rustc invokes the linker doesn't
# work with GCC 6: https://bugzilla.mozilla.org/show_bug.cgi?id=1477305
#
# We don't pass HOST_{CC,CXX} down in any form because our host value might not match
# what cargo chooses and there's no way to control cargo's selection, so we just have to
# hope that if something needs to build a host C source file it can find a usable compiler!
#

# We start with host variables because the rust host and the rust target might be the same,
# in which case we want the latter to take priority.

# We're passing these for consumption by the `cc` crate, which doesn't use the same
# convention as cargo itself:
# https://github.com/alexcrichton/cc-rs/blob/baa71c0e298d9ad7ac30f0ad78f20b4b3b3a8fb2/src/lib.rs#L1715
rust_host_cc_env_name := $(subst -,_,$(RUST_HOST_TARGET))

export CC_$(rust_host_cc_env_name)=$(HOST_CC)
export CXX_$(rust_host_cc_env_name)=$(HOST_CXX)
export CFLAGS_$(rust_host_cc_env_name)=$(COMPUTED_HOST_CFLAGS)
export CXXFLAGS_$(rust_host_cc_env_name)=$(COMPUTED_HOST_CXXFLAGS)
# We don't have a HOST_AR. If rust needs one, assume it's going to pick an appropriate one.

rust_cc_env_name := $(subst -,_,$(RUST_TARGET))

export CC_$(rust_cc_env_name)=$(CC)
Expand Down

0 comments on commit 401ecc4

Please sign in to comment.