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

Use -- to separate flags and options from input filenames #513

Open
ncalexan opened this issue Jun 9, 2020 · 2 comments
Open

Use -- to separate flags and options from input filenames #513

ncalexan opened this issue Jun 9, 2020 · 2 comments

Comments

@ncalexan
Copy link
Contributor

ncalexan commented Jun 9, 2020

I'm in the unusual position of trying to cross-compile from macOS to Windows with clang-cl (building Firefox, but that's not really relevant). I'm running into the [-Wslash-u-filename] warning, like so:

running: "/Users/nalexander/.mozbuild/clang/bin/clang-cl" "-Xclang" "-std=gnu99" "-nologo" "-MD" "-O1" "-Z7" "-Brepro" "-m64" "-Xclang" "-ftrivial-auto-var-init=pattern" "-guard:cf" "-DDEBUG=1" "-I/Users/nalexander/Mozilla/gecko/toolkit/library/rust" "-I/Users/nalexander/Mozilla/objdirs/objdir-windows-compile/toolkit/library/rust" "-I/Users/nalexander/Mozilla/objdirs/objdir-windows-compile/dist/include" "-I/Users/nalexander/Mozilla/objdirs/objdir-windows-compile/dist/include/nspr" "-I/Users/nalexander/Mozilla/objdirs/objdir-windows-compile/dist/include/nss" "-MD" "-FI" "/Users/nalexander/Mozilla/objdirs/objdir-windows-compile/mozilla-config.h" "-DMOZILLA_CLIENT" "-Qunused-arguments" "-D_HAS_EXCEPTIONS=0" "-W3" "-Gy" "-Zc:inline" "-Gw" "-Wno-unknown-pragmas" "-Wno-ignored-pragmas" "-Wno-deprecated-declarations" "-Wno-invalid-noreturn" "-Z7" "-O2" "-Oy-" "-DMOZILLA_CONFIG_H" "-DMDB_IDL_LOGN=9" "-Fo/Users/nalexander/Mozilla/objdirs/objdir-windows-compile/x86_64-pc-windows-msvc/debug/build/lmdb-rkv-sys-e159e1f997d95e72/out/mdb.o" "-c" "/Users/nalexander/Mozilla/gecko/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c"
cargo:warning=clang-9: warning: '/Users/nalexander/Mozilla/gecko/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c' treated as the '/U' option [-Wslash-u-filename]
cargo:warning=clang-9: note: Use '--' to treat subsequent arguments as filenames
cargo:warning=clang-9: error: no input files
exit code: 1

What's needed in these situations is to insert -- before the input filename. Given that cc-rs must already be normalizing its Builder outputs, this seems straight-forward enough, but it's technically possible that supported C/C++ compilers wouldn't accept --.

Would the project take a patch?

@alexcrichton
Copy link
Member

Thanks for the report! This should be relatively easy to fix I think since we should already know whether the type of the compiler is clang/gnu/etc. Given that we could just arrange for the filename to always be at the end and then, for clang-cl, always use -- before the filename?

ncalexan added a commit to ncalexan/cc-rs that referenced this issue Jun 9, 2020
)

This avoids a `clang-cl` issue common when cross-compiling from macOS
to Windows: the `-Wslash-u-filename` where a `/Users/...` path is
interpreted as the `cl.exe` flag `/U`.

In general it's somewhere between harmless and good form to separate
flags/options from input files, so `--` is used for all compilers save
MSVC.

There are no existing tests mocking out `clang-cl` and surface efforts
didn't succeed, so that will have to wait for follow-up.
ncalexan added a commit to ncalexan/cc-rs that referenced this issue Jun 10, 2020
…h-u-filename`. (rust-lang#513)

This avoids a `clang-cl` issue common when cross-compiling from macOS
to Windows: the `-Wslash-u-filename` where a `/Users/...` path is
interpreted as the `cl.exe` flag `/U`.

Not all compilers recognize `--` so this is limited to `clang-cl`.

There are no existing tests mocking out `clang-cl` and surface efforts
didn't succeed, so that will have to wait for follow-up.
@mathewhodson
Copy link

@ncalexan I believe this is fixed by #514

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 a pull request may close this issue.

3 participants