Skip to content

Bundled gcc/libraries on windows may cause errors when compiling native code #19519

Closed
@alexcrichton

Description

@alexcrichton

I have just run into a problem when building Cargo that looks like as follows:

  • Cargo relies on a number of libraries from the MinGW installation, so when it downloads a Rust snapshot compiler we delete the gcc.exe in the distribution.
  • On Windows, we build libcurl from source using a checked in configure script. This configure script runs against the system gcc.
  • The libcurl configure script detects that strtok_r is available on the local system in the libmingwex.a library in the /mingw64/x86_64-w64-mingw32/lib directory. The configure script detects this by running the system gcc against a test file.
  • When Cargo itself is linked together it uses the system gcc again, but this time it has a -L flag to the directory where all the Rust bundled gcc libraries are.
  • It turns out that Rust ships a libmingwex.a, and this used instead of the /mingw64 one. It also turns out that this libmingwex.a that we ship does not contain strtok_r.
  • The linking step for Cargo fails because libcurl expected to find strtok_r in libmingwex.a, but the wrong libmingwex.a was linked in so the symbol was ultimately undefined.

I think we may want an installation option for Rust which opts out of installing the bundled gcc compiler (but we still do it by default) to solve this. cc @vadimcn, @brson.

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions