Skip to content

make: building rust crate should depend on all of its sub crates #8056

Closed
@pnkfelix

Description

@pnkfelix

Right now the tests.mk file has lines like this:

TEST_TARGET_CRATES = std extra
TEST_HOST_CRATES = syntax rustc rustdoc rust rustpkg rusti
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
...
$(3)/stage$(1)/test/rusttest-$(2)$$(X_$(2)): \
$$(RUST_LIB) $$(RUST_INPUTS)    \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test

When I do make check-stage1 --trace with remake, I get the following problem:

Invoking recipe from /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:372 to update target `x86_64-apple-darwin/stage1/test/rusttest-x86_64-apple-darwin'.
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
echo  compile_and_link: x86_64-apple-darwin/stage1/test/rusttest-x86_64-apple-darwin
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
compile_and_link: x86_64-apple-darwin/stage1/test/rusttest-x86_64-apple-darwin
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
x86_64-apple-darwin/stage1/bin/rustc --cfg stage1  -O --cfg debug -Z no-debug-borrows --target=x86_64-apple-darwin  -o x86_64-apple-darwin/stage1/test/rusttest-x86_64-apple-darwin /Users/pnkfelix/Dev/Mozilla/rust-basis7081/src/librust/rust.rs --test
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/Users/pnkfelix/Dev/Mozilla/rust-basis7081/src/librust/rust.rs:23:0: 23:19 error: can't find crate for `rustpkg`
/Users/pnkfelix/Dev/Mozilla/rust-basis7081/src/librust/rust.rs:23 extern mod rustpkg;
                                                                  ^~~~~~~~~~~~~~~~~~~
/Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:372: *** [x86_64-apple-darwin/stage1/test/rusttest-x86_64-apple-darwin] Error 101

#0  x86_64-apple-darwin/stage1/test/rusttest-x86_64-apple-darwin at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:372
#1  tmp/check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-rust.ok at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:425
#2  check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-rust-exec at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:425
#3  check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-crates-exec at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:300
#4  check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin-exec at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:300
#5  check-stage1-T-x86_64-apple-darwin-H-x86_64-apple-darwin at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:730
#6  check-stage1-H-x86_64-apple-darwin at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:770
#7  check-stage1 at /Users/pnkfelix/Dev/Mozilla/rust-basis7081/mk/tests.mk:751
Command-line invocation:
    "/Users/pnkfelix/opt-remake/bin/remake check-stage1 --trace"

Namely, building rusttest fails because the rust crate needs the crates for rustc, rustdoc, etc to already have been built; but in this case, the rustpkg crate has not yet been built.

This probably manifests in this manner because rustpkg comes after rust in the definition for TEST_HOST_CRATES. Maybe the fact that the extern entry for rustpkg comes first in the rust.rs file has something to do with it too.

For my local checkout, it seems like one can hack around the problem by moving rust to the end of the TEST_HOST_CRATES definition. But that is a fragile fix: It does not properly indicate the relationship between these entities.

A more appropriate fix would be for the Makefile to indicate that rusttest has a direct or indirect dependence on the rustpkg crate, as well as all the other crates it uses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions