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

overriding '/MT' with '/MD' #40246

Closed
steveklabnik opened this issue Mar 3, 2017 · 6 comments · Fixed by rust-lang/cc-rs#159 or rust-lang/cmake-rs#31
Closed

overriding '/MT' with '/MD' #40246

steveklabnik opened this issue Mar 3, 2017 · 6 comments · Fixed by rust-lang/cc-rs#159 or rust-lang/cmake-rs#31
Labels
O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@steveklabnik
Copy link
Member

Here's an excerpt from building rustc:

Building stage1 compiler artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc)
   Compiling graphviz v0.0.0 (file:///C:/Users/steve/src/rust/src/libgraphviz)
   Compiling log v0.0.0 (file:///C:/Users/steve/src/rust/src/liblog)
   Compiling arena v0.0.0 (file:///C:/Users/steve/src/rust/src/libarena)
   Compiling gcc v0.3.43
   Compiling rustc_platform_intrinsics v0.0.0 (file:///C:/Users/steve/src/rust/src/librustc_platform_intrinsics)
   Compiling rustc_bitflags v0.0.0 (file:///C:/Users/steve/src/rust/src/librustc_bitflags)
   Compiling serialize v0.0.0 (file:///C:/Users/steve/src/rust/src/libserialize)
   Compiling fmt_macros v0.0.0 (file:///C:/Users/steve/src/rust/src/libfmt_macros)
   Compiling libc v0.2.20
   Compiling filetime v0.1.10
   Compiling build_helper v0.1.0 (file:///C:/Users/steve/src/rust/src/build_helper)
   Compiling flate v0.0.0 (file:///C:/Users/steve/src/rust/src/libflate)
   Compiling rustdoc v0.0.0 (file:///C:/Users/steve/src/rust/src/librustdoc)
   Compiling rustc_llvm v0.0.0 (file:///C:/Users/steve/src/rust/src/librustc_llvm)
   Compiling syntax_pos v0.0.0 (file:///C:/Users/steve/src/rust/src/libsyntax_pos)
   Compiling rustc_data_structures v0.0.0 (file:///C:/Users/steve/src/rust/src/librustc_data_structures)
   Compiling rustc_errors v0.0.0 (file:///C:/Users/steve/src/rust/src/librustc_errors)
warning: cl : Command line warning D9025 : overriding '/MT' with '/MD'
warning: cl : Command line warning D9025 : overriding '/MD' with '/MT'
warning: cl : Command line warning D9025 : overriding '/MT' with '/MD'
warning: cl : Command line warning D9025 : overriding '/MD' with '/MT'
warning: cl : Command line warning D9025 : overriding '/MT' with '/MD'
warning: cl : Command line warning D9025 : overriding '/MD' with '/MT'
   Compiling syntax v0.0.0 (file:///C:/Users/steve/src/rust/src/libsyntax)

I don't know what these warnings are, and the build seems to work, but seems bad maybe?

@steveklabnik steveklabnik added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) O-windows-msvc Toolchain: MSVC, Operating system: Windows labels Mar 3, 2017
@luser
Copy link
Contributor

luser commented Mar 3, 2017

These switches select either the static or DLL version of the CRT. If you try to mix code that was compiled with different settings you'll usually get a linker error, so that must not be happening.

@retep998
Copy link
Member

retep998 commented Mar 3, 2017

This is very likely due to #39837. Should be a simple matter of figuring out which compiler invocation is passing /MD and tracing it back into the build system and fixing the bit responsible.

cc @alexcrichton

@alexcrichton
Copy link
Member

I believe the last time I checked this was because LLVM passes /MD unconditionally, we then configure it to pass /MT so it passes that later. We then ourselves also pass /MT ahead of things which ends up with:

  • Our /MT is first
  • LLVM's /MD is next, unsure how to remove this
  • LLVM's /MT is last

The last one wins, which is what we care about, but it'd be great to fix this! I may also be wrong in this diagnosis, this is just from memory.

@liranringel
Copy link
Contributor

liranringel commented May 6, 2017

@alexcrichton is right, llvm passed /MD.
I added the following lines to llvm-config/CMakeLists.txt, after LLVM_CFLAGS and LLVM_CXXFLAGS are set:

set(CompilerFlags
LLVM_CFLAGS
LLVM_CXXFLAGS
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()

That indeed resolved the issue, but it probably be better if we could achieve that by editing the cmake::Config in src/bootstrap/native.rs. I hope I'll have time to check that later today.

Edit: If I understand it correctly, the bootstrap project is not compiled with +static-crt, so here:
https://github.com/rust-lang/rust/blob/master/src/bootstrap/cc.rs#L77
it returns the flag /MD (see https://github.com/alexcrichton/gcc-rs/blob/master/src/lib.rs#L542), which is used later here: https://github.com/rust-lang/rust/blob/master/src/bootstrap/native.rs#L179
Perhaps gcc-rs should provide a mean to explicitly set the crt-static flag?

@retep998
Copy link
Member

This should remain open until the version of gcc and cmake that Rust itself uses are updated.

@retep998
Copy link
Member

This should remain open until #41959 lands.

@retep998 retep998 reopened this May 12, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 13, 2017
…-cmake-config, r=alexcrichton

Pass static crt to llvm cmake configuration

Solves rust-lang#40246
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 14, 2017
…-cmake-config, r=alexcrichton

Pass static crt to llvm cmake configuration

Solves rust-lang#40246
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants