Define rustc's host triple at compile time
This way a cross-compiled rustc's answer to host_triple() is correct. The return value of host_triple() reflects the actual host triple that the compiler was build for, not the triple the compiler is being built on
This commit is contained in:
parent
5f90f1ca1d
commit
ff86830c9c
|
@ -8,6 +8,11 @@
|
||||||
# option. This file may not be copied, modified, or distributed
|
# option. This file may not be copied, modified, or distributed
|
||||||
# except according to those terms.
|
# except according to those terms.
|
||||||
|
|
||||||
|
# This is the compile-time target-triple for the compiler. For the compiler at
|
||||||
|
# runtime, this should be considered the host-triple. More explanation for why
|
||||||
|
# this exists can be found on issue #2400
|
||||||
|
export CFG_COMPILER_TRIPLE
|
||||||
|
|
||||||
# TARGET_STAGE_N template: This defines how target artifacts are built
|
# TARGET_STAGE_N template: This defines how target artifacts are built
|
||||||
# for all stage/target architecture combinations. The arguments:
|
# for all stage/target architecture combinations. The arguments:
|
||||||
# $(1) is the stage
|
# $(1) is the stage
|
||||||
|
@ -62,6 +67,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
|
||||||
@$$(call E, cp: $$@)
|
@$$(call E, cp: $$@)
|
||||||
$$(Q)cp $$< $$@
|
$$(Q)cp $$< $$@
|
||||||
|
|
||||||
|
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): CFG_COMPILER_TRIPLE = $(2)
|
||||||
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
|
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
|
||||||
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||||
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)) \
|
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)) \
|
||||||
|
|
|
@ -307,6 +307,7 @@ $(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)): \
|
||||||
@$$(call E, compile_and_link: $$@)
|
@$$(call E, compile_and_link: $$@)
|
||||||
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
|
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
|
||||||
|
|
||||||
|
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER_TRIPLE = $(2)
|
||||||
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): \
|
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): \
|
||||||
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||||
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
|
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
|
||||||
|
|
|
@ -516,15 +516,15 @@ pub fn host_triple() -> ~str {
|
||||||
// idea of the host triple is the same as for the set of libraries we've
|
// idea of the host triple is the same as for the set of libraries we've
|
||||||
// actually built. We can't just take LLVM's host triple because they
|
// actually built. We can't just take LLVM's host triple because they
|
||||||
// normalize all ix86 architectures to i386.
|
// normalize all ix86 architectures to i386.
|
||||||
|
//
|
||||||
// FIXME (#2400): Instead of grabbing the host triple we really should
|
// Instead of grabbing the host triple (for the current host), we grab (at
|
||||||
// be grabbing (at compile time) the target triple that this rustc is
|
// compile time) the target triple that this rustc is built with and
|
||||||
// built with and calling that (at runtime) the host triple.
|
// calling that (at runtime) the host triple.
|
||||||
let ht = env!("CFG_BUILD_TRIPLE");
|
let ht = env!("CFG_COMPILER_TRIPLE");
|
||||||
return if ht != ~"" {
|
return if ht != ~"" {
|
||||||
ht
|
ht
|
||||||
} else {
|
} else {
|
||||||
fail!("rustc built without CFG_BUILD_TRIPLE")
|
fail!("rustc built without CFG_COMPILER_TRIPLE")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,15 +534,15 @@ pub fn host_triple() -> ~str {
|
||||||
// idea of the host triple is the same as for the set of libraries we've
|
// idea of the host triple is the same as for the set of libraries we've
|
||||||
// actually built. We can't just take LLVM's host triple because they
|
// actually built. We can't just take LLVM's host triple because they
|
||||||
// normalize all ix86 architectures to i386.
|
// normalize all ix86 architectures to i386.
|
||||||
|
//
|
||||||
// FIXME (#2400): Instead of grabbing the host triple we really should
|
// Instead of grabbing the host triple (for the current host), we grab (at
|
||||||
// be grabbing (at compile time) the target triple that this rustc is
|
// compile time) the target triple that this rustc is built with and
|
||||||
// built with and calling that (at runtime) the host triple.
|
// calling that (at runtime) the host triple.
|
||||||
let ht = env!("CFG_BUILD_TRIPLE");
|
let ht = env!("CFG_COMPILER_TRIPLE");
|
||||||
return if ht != "" {
|
return if ht != "" {
|
||||||
ht.to_owned()
|
ht.to_owned()
|
||||||
} else {
|
} else {
|
||||||
fail!("rustc built without CFG_BUILD_TRIPLE")
|
fail!("rustc built without CFG_COMPILER_TRIPLE")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue