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

Cross compiling from macOS to Emscripten fails because of automatically added -stdlib=libc++ #7339

Open
1 task done
sascha opened this issue Jul 10, 2020 · 4 comments
Open
1 task done

Comments

@sascha
Copy link

sascha commented Jul 10, 2020

Environment Details

  • Operating System+version: macOS 10.15.5
  • Compiler+version: Apple clang version 11.0.3 and Emscripten 1.39.19
  • Conan version: 1.27.0
  • Python version: 3.7.7

Problem description

I'm not quite sure if this is a bug, a missing feature or a configuration error, but the issue is somewhat related to issue #2856. Just like Android, the Emscripten compiler does not need -stdlib=libc++. I could probably get around this issue by specifying compiler.libcxx=c++_static in the host profile in which case the conan_set_libcxx macro in the generated CMake file would not add the -stdlib=libc++ flag, however this is only a valid option when setting the compiler to clang. On the other hand I can't set the compiler to clang, because the highest available version number is 10 while the latest version number of apple-clang is 11. This mismatch will throw an error when installing packages, because Emscripten's toolchain file automatically sets the compiler version to that of the system clang.

Ideally I'd need a way to remove the compiler.libcxx setting when the host os is Emscripten. Is there a way to do this?

@jgsogo
Copy link
Contributor

jgsogo commented Jul 13, 2020

Hi @sascha ! Can you share with us the Emscripten recipe you are using? or how are you populating the environment before running Conan to compile your library?

@sascha
Copy link
Author

sascha commented Jul 14, 2020

Hi @jgsogo, sure, happy to.

I'm installing my Conan deps with

conan install . -if _builds/cesdk/wasm32-unknown-emscripten/debug -s build_type=Debug --build=missing -pr:h=conan/profiles/emscripten -pr:b=default

This is my emscripten profile:

include(default)

[settings]
os=Emscripten
arch=wasm

[build_requires]
emsdk_installer/1.39.19@imgly/stable

and this is my default profile:

[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=11.0
compiler.libcxx=libc++
build_type=Release

The emsdk_installer/1.39.19@imgly/stable is pretty much the same as https://github.com/bincrafters/conan-emsdk_installer except that it's updated to the latest version of Emscripten and the lines at https://github.com/bincrafters/conan-emsdk_installer/blob/testing/1.39.13/conanfile.py#L13-L16 have been replaced with a simple settings = "os", "arch" to support the newer host/build profiles.

One of my dependencies is gtest/1.10.0 for which I run into the following error when running conan install with above setup:

clang++: error: argument unused during compilation: '-stdlib=libc++' [-Werror,-Wunused-command-line-argument]

The emscripten compiler frontend is basically a drop-in replacement for clang (https://emscripten.org/docs/tools_reference/emcc.html). Would it make sense to introduce a new compiler setting?

@lkotsonis
Copy link

Any update on this? I bumped into the same issue

@jgsogo
Copy link
Contributor

jgsogo commented Sep 27, 2021

I've been playing with emscripten these days (I'm using the recipe under development here: conan-io/conan-center-index#6163). With the build-requires, I'm able to build corrade (conan-io/conan-center-index#7410) and magnum packages (conan-io/conan-center-index#7412) with some modifications. It also works for magnum-integration, magnum-extras,... those are a bunch of packages.

I'm still working on several pull-requests for different packages, but so far it is working for them: conan-io/conan-center-index#6292.

(All of this, using the latest Conan version)

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

No branches or pull requests

3 participants