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

Cannot cross-compile to windows if using C compiler in build script #796

Open
Srinivasa314 opened this issue Jun 1, 2020 · 9 comments
Open
Labels
A-builds Area: Building the documentation for a crate C-build-failure Category: This is a crate that failed to build

Comments

@Srinivasa314
Copy link

After a day documentation is still not built for version 0.1.4. In version 0.1.3, there is no documentation for windows and the example in the crate level documentation does not contain the code I added in version 0.1.3.

@Nemo157
Copy link
Member

Nemo157 commented Jun 1, 2020

Going backwards through the issues:

The 0.1.3 crate level docs appear to match the source from crates.io. (Checked with cargo download -x alcro==0.1.3).


The windows documentation build failed because tinyfiledialog builds a native library, which I don't think is possible for Windows on docs.rs yet. (@jyn514 do we actually have any issue tracking problems with targetting x86_64-pc-windows-msvc?).


The 0.1.4 build failed because it believes the Cargo.lock needs to be updated

error: the lock file /opt/docsrs/rustwide/builds/alcro-0.1.4/source/Cargo.lock needs to be updated but --locked was passed to prevent this

There's a bug that docs.rs does not record build status if it fails this early (#797). And the actual failure seems to be a cargo bug, docs.rs regenerates the lockfile if it fails to fetch the sources, but it seems even the regenerated lockfile doesn't work (rust-lang/cargo#8302).

@jyn514
Copy link
Member

jyn514 commented Jun 1, 2020

The windows documentation build failed because tinyfiledialog builds a native library, which I don't think is possible for Windows on docs.rs yet. (@jyn514 do we actually have any issue tracking problems with targetting x86_64-pc-windows-msvc?)

From my understanding, the build failed because we cross-compiled from Linux to Windows? I think we should make an issues for failures due to cross-compilation, not for windows specifically.

@Nemo157
Copy link
Member

Nemo157 commented Jun 1, 2020

Sure, a general issue about cross compilation would be useful, but the reasons for different targets are going to be different enough that it might be useful to have sub-issues for them (e.g. cross-compiling to x86_64-pc-windows-gnu is easy, it just requires adding in more tools to the build-env, for -msvc I’m not sure if there’s a solution to the lack of link.exe).

@jyn514
Copy link
Member

jyn514 commented Jun 1, 2020

cross-compiling to x86_64-pc-windows-gnu is easy, it just requires adding in more tools to the build-env

This is not usually the case. Most build failures are because pkg-config disables cross-compilation by default:

Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override

That will be an issue regardless of the target. Can you paste the error that alcro has for windows so I can see what failed?

@Nemo157
Copy link
Member

Nemo157 commented Jun 1, 2020

For x86_64-pc-windows-msvc (ignoring the failure because of tinyfiledialog writing temporary files to the source folder):

running: "lib.exe" "-out:/alcro-0.1.3/target/x86_64-pc-windows-msvc/debug/build/tinyfiledialogs-843c895d48dd6318/out/libtinyfiledialogs.a" "-nologo" "/alcro-0.1.3/target/x86_64-pc-windows-msvc/debug/build/tinyfiledialogs-843c895d48dd6318/out/libtinyfiledialogs/tinyfiledialogs.o"

--- stderr
error occurred: Failed to find tool. Is `lib.exe` installed?

For x86_64-pc-windows-gnu:

running: "x86_64-w64-mingw32-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-v" "-o" "/alcro-0.1.3/target/x86_64-pc-windows-gnu/debug/build/tinyfiledialogs-a43b97fc6b9fcef9/out/libtinyfiledialogs/tinyfiledialogs.o" "-c" "libtinyfiledialogs/tinyfiledialogs.c"

--- stderr
error occurred: Failed to find tool. Is `x86_64-w64-mingw32-gcc` installed?

then after an apt install gcc-mingw-w64 it successfully built the documentation.

@Srinivasa314
Copy link
Author

Srinivasa314 commented Jun 5, 2020

UPDATE: I fixed a bug in version 0.1.4 so I yanked it. Also I changed the version of winapi from ^0 to ^0.3. Documentation for 0.1.5 appears only for linux and macos in docs.rs

edit : For the tinyfiledialogs crate also documentation only appears for linux and macos in docs.rs

@jyn514 jyn514 changed the title Problems with documentation for alcro crate Cannot cross-compile to windows if using C compiler in build script Jun 27, 2020
@jyn514
Copy link
Member

jyn514 commented Jun 27, 2020

The relevant code is https://docs.rs/crate/tinyfiledialogs/3.3.9/source/build.rs, which calls cc libtinyfiledialogs/tinyfiledialogs.c. I'm not sure this is actually a docs.rs bug, it seems to me that it should be trying to use the host compiler toolchain and cross-compiling itself (currently it tries to compile using the target toolchain which obviously fails).

@jyn514
Copy link
Member

jyn514 commented Jun 27, 2020

Yeah, this is a bug in the cc crate. I opened rust-lang/cc-rs#523.

@jyn514 jyn514 added A-builds Area: Building the documentation for a crate C-build-failure Category: This is a crate that failed to build labels Jul 13, 2020
@syphar
Copy link
Member

syphar commented Oct 24, 2023

@Nemo157 from what I see in the comments this build failure was not a docs.rs issue? So we can close this?

Or did this issue grow into "we need to natively build on windows"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builds Area: Building the documentation for a crate C-build-failure Category: This is a crate that failed to build
Projects
None yet
Development

No branches or pull requests

4 participants