70269cd8ef
The path we pass to rustc will be visible in panic messages and backtraces: they will be user visible! Avoid junk in these paths by passing relative paths to rustc. For most advanced users, `libcore` or `libstd` in the path will be a clue to the location -- inside our code, not theirs. Store both the relative path to the source as well as the absolute. Use the relative path where it matters, compiling the main crates, instead of changing all of the build process to cope with relative paths. Example output after this patch: ``` $ ./testunwrap thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:362 $ RUST_BACKTRACE=1 ./testunwrap thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:362 stack backtrace: 1: 0x7ff59c1e9956 - sys::backtrace::write::h67a542fd2b201576des at ../src/libstd/sys/unix/backtrace.rs:158 2: 0x7ff59c1ed5b6 - panicking::on_panic::h3d21c41cdd5c12d41Xw at ../src/libstd/panicking.rs:58 3: 0x7ff59c1e7b6e - rt::unwind::begin_unwind_inner::h9f3a5440cebb8baeLDw at ../src/libstd/rt/unwind/mod.rs:273 4: 0x7ff59c1e7f84 - rt::unwind::begin_unwind_fmt::h4fe8a903e0c296b0RCw at ../src/libstd/rt/unwind/mod.rs:212 5: 0x7ff59c1eced7 - rust_begin_unwind 6: 0x7ff59c22c11a - panicking::panic_fmt::h00b0cd49c98a9220i5B at ../src/libcore/panicking.rs:64 7: 0x7ff59c22b9e0 - panicking::panic::hf549420c0ee03339P3B at ../src/libcore/panicking.rs:45 8: 0x7ff59c1e621d - option::Option<T>::unwrap::h501963526474862829 9: 0x7ff59c1e61b1 - main::hb5c91ce92347d1e6eaa 10: 0x7ff59c1f1c18 - rust_try_inner 11: 0x7ff59c1f1c05 - rust_try 12: 0x7ff59c1ef374 - rt::lang_start::h7e51e19c6677cffe5Sw at ../src/libstd/rt/unwind/mod.rs:147 at ../src/libstd/rt/unwind/mod.rs:130 at ../src/libstd/rt/mod.rs:128 13: 0x7ff59c1e628e - main 14: 0x7ff59b3f6b44 - __libc_start_main 15: 0x7ff59c1e6078 - <unknown> 16: 0x0 - <unknown> ```
157 lines
6.1 KiB
Makefile
157 lines
6.1 KiB
Makefile
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
# file at the top-level directory of this distribution and at
|
|
# http://rust-lang.org/COPYRIGHT.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
# option. This file may not be copied, modified, or distributed
|
|
# except according to those terms.
|
|
|
|
################################################################################
|
|
# Rust's standard distribution of crates and tools
|
|
#
|
|
# The crates outlined below are the standard distribution of libraries provided
|
|
# in a rust installation. These rules are meant to abstract over the
|
|
# dependencies (both native and rust) of crates and basically generate all the
|
|
# necessary makefile rules necessary to build everything.
|
|
#
|
|
# Here's an explanation of the variables below
|
|
#
|
|
# TARGET_CRATES
|
|
# This list of crates will be built for all targets, including
|
|
# cross-compiled targets
|
|
#
|
|
# HOST_CRATES
|
|
# This list of crates will be compiled for only host targets. Note that
|
|
# this set is explicitly *not* a subset of TARGET_CRATES, but rather it is
|
|
# a disjoint set. Nothing in the TARGET_CRATES set can depend on crates in
|
|
# the HOST_CRATES set, but the HOST_CRATES set can depend on target
|
|
# crates.
|
|
#
|
|
# TOOLS
|
|
# A list of all tools which will be built as part of the compilation
|
|
# process. It is currently assumed that most tools are built through
|
|
# src/driver/driver.rs with a particular configuration (there's a
|
|
# corresponding library providing the implementation)
|
|
#
|
|
# DEPS_<crate>
|
|
# These lists are the dependencies of the <crate> that is to be built.
|
|
# Rust dependencies are listed bare (i.e. std) and native
|
|
# dependencies have a "native:" prefix (i.e. native:hoedown). All deps
|
|
# will be built before the crate itself is built.
|
|
#
|
|
# TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
|
|
# Similar to the DEPS variable, this is the library crate dependencies
|
|
# list for tool as well as the source file for the specified tool
|
|
#
|
|
# You shouldn't need to modify much other than these variables. Crates are
|
|
# automatically generated for all stage/host/target combinations.
|
|
################################################################################
|
|
|
|
TARGET_CRATES := libc std flate arena term \
|
|
serialize getopts collections test rand \
|
|
log graphviz core rbml alloc \
|
|
rustc_unicode rustc_bitflags
|
|
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
|
|
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
|
|
rustc_data_structures
|
|
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
|
|
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
|
|
TOOLS := compiletest rustdoc rustc rustbook error-index-generator
|
|
|
|
DEPS_core :=
|
|
DEPS_libc := core
|
|
DEPS_rustc_unicode := core
|
|
DEPS_alloc := core libc native:jemalloc
|
|
DEPS_std := core libc rand alloc collections rustc_unicode \
|
|
native:rust_builtin native:backtrace native:rustrt_native \
|
|
rustc_bitflags
|
|
DEPS_graphviz := std
|
|
DEPS_syntax := std term serialize log fmt_macros arena libc
|
|
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
|
|
rustc_typeck rustc_resolve log syntax serialize rustc_llvm \
|
|
rustc_trans rustc_privacy rustc_lint
|
|
|
|
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
|
|
log syntax serialize rustc_llvm
|
|
DEPS_rustc_typeck := rustc syntax
|
|
DEPS_rustc_borrowck := rustc log graphviz syntax
|
|
DEPS_rustc_resolve := rustc log syntax
|
|
DEPS_rustc_privacy := rustc log syntax
|
|
DEPS_rustc_lint := rustc log syntax
|
|
DEPS_rustc := syntax flate arena serialize getopts rbml \
|
|
log graphviz rustc_llvm rustc_back rustc_data_structures
|
|
DEPS_rustc_llvm := native:rustllvm libc std
|
|
DEPS_rustc_back := std syntax rustc_llvm flate log libc
|
|
DEPS_rustc_data_structures := std log serialize
|
|
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
|
|
test rustc_lint
|
|
DEPS_rustc_bitflags := core
|
|
DEPS_flate := std native:miniz
|
|
DEPS_arena := std
|
|
DEPS_graphviz := std
|
|
DEPS_glob := std
|
|
DEPS_serialize := std log
|
|
DEPS_rbml := std log serialize
|
|
DEPS_term := std log
|
|
DEPS_getopts := std
|
|
DEPS_collections := core alloc rustc_unicode
|
|
DEPS_num := std
|
|
DEPS_test := std getopts serialize rbml term native:rust_test_helpers
|
|
DEPS_rand := core
|
|
DEPS_log := std
|
|
DEPS_fmt_macros = std
|
|
|
|
TOOL_DEPS_compiletest := test getopts
|
|
TOOL_DEPS_rustdoc := rustdoc
|
|
TOOL_DEPS_rustc := rustc_driver
|
|
TOOL_DEPS_rustbook := std rustdoc
|
|
TOOL_DEPS_error-index-generator := rustdoc syntax serialize
|
|
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
|
|
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
|
|
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
|
|
TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs
|
|
TOOL_SOURCE_error-index-generator := $(S)src/error-index-generator/main.rs
|
|
|
|
ONLY_RLIB_core := 1
|
|
ONLY_RLIB_libc := 1
|
|
ONLY_RLIB_alloc := 1
|
|
ONLY_RLIB_rand := 1
|
|
ONLY_RLIB_collections := 1
|
|
ONLY_RLIB_rustc_unicode := 1
|
|
ONLY_RLIB_rustc_bitflags := 1
|
|
|
|
# Documented-by-default crates
|
|
DOC_CRATES := std alloc collections core libc rustc_unicode
|
|
|
|
################################################################################
|
|
# You should not need to edit below this line
|
|
################################################################################
|
|
|
|
# This macro creates some simple definitions for each crate being built, just
|
|
# some munging of all of the parameters above.
|
|
#
|
|
# $(1) is the crate to generate variables for
|
|
define RUST_CRATE
|
|
CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
|
|
RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
|
|
RUST_DEPS_$(1) := $$(filter-out native:%,$$(DEPS_$(1)))
|
|
NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
|
|
endef
|
|
|
|
$(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
|
|
|
|
# Similar to the macro above for crates, this macro is for tools
|
|
#
|
|
# $(1) is the crate to generate variables for
|
|
define RUST_TOOL
|
|
TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
|
|
endef
|
|
|
|
$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
|
|
|
|
ifdef CFG_DISABLE_ELF_TLS
|
|
RUSTFLAGS_std := --cfg no_elf_tls
|
|
endif
|