Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail fast and more helpfully on invalid compile argument #655

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Feb 14, 2022

The argument of compile can cause a variety of interesting misbehaviors later on if it's anything other than a single path component. compile("foo/bar") fails with:

error: ar: /path/to/target/debug/build/repro-2641eaae14bc95dd/out/libfoo/bar.a: No such file or directory

compile("") fails with:

error: empty library name given via `-l`

compile("/tmp") fails with:

error: ar: /git/cxx/target/debug/build/demo-2641eaae14bc95dd/out/lib/tmp.a: No such file or directory

All of these are probably different from what the user had in mind. This PR adds an assertion that the compile argument consists of a single "normal" path component i.e. not containing path separators or anything else probably wrong. Choosing an argument for compile is already confusing for people because it can pretty much be arbitrary, but the intent is that it's supposed to be an arbitrary single path component.

@dtolnay
Copy link
Member Author

dtolnay commented Feb 14, 2022

Test failure on Windows seems unrelated to this PR and has failed the same way on other PRs according to https://github.com/alexcrichton/cc-rs/actions/workflows/main.yml. Can't tell what failed though.... something silently crashed after running only 23 of the 31 tests in tests/test.rs.
running 31 tests
test gnu_debug_fp ... ok
test gnu_compile_assembly ... ok
test gnu_debug_fp_auto ... ok
test gnu_define ... ok
test gnu_debug_nofp ... ok
test gnu_extra_warnings0 ... ok
test gnu_flag_if_supported ... ok
test gnu_flag_if_supported_cpp ... ok
test gnu_extra_warnings1 ... ok
test gnu_i686 ... ok
test gnu_i686_pic ... ok
test gnu_include ... ok
test gnu_opt_level_1 ... ok
test gnu_opt_level_s ... ok
test gnu_set_stdlib ... ok
test gnu_shared ... ok
test gnu_smoke ... ok
test gnu_static ... ok
test gnu_warnings ... ok
test gnu_warnings_into_errors ... ok
test gnu_warnings_overridable ... ok
test gnu_x86_64 ... ok
test gnu_x86_64_no_pic ... ok
error: test failed, to rerun pass '--test test'
Error: Process completed with exit code 1.

@alexcrichton
Copy link
Member

Could the documentation of this method be updated as well? Other than that seems good to me! I also don't know what's going on with CI unfortunately.

@alexcrichton alexcrichton merged commit 421f06b into rust-lang:main Feb 15, 2022
@dtolnay dtolnay deleted the compilearg branch February 15, 2022 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants