Skip to content

emsdk: new recipe #4

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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open

emsdk: new recipe #4

wants to merge 36 commits into from

Conversation

perseoGI
Copy link
Contributor

@perseoGI perseoGI commented Jun 13, 2025

Summary

Original PR conan-io/conan-center-index#27213

@perseoGI perseoGI assigned jcar87 and unassigned jcar87 Jun 16, 2025
@AbrilRBS AbrilRBS self-requested a review June 16, 2025 09:43
@CLAassistant
Copy link

CLAassistant commented Jun 16, 2025

CLA assistant check
All committers have signed the CLA.

@perseoGI perseoGI marked this pull request as ready for review June 17, 2025 09:37
@perseoGI
Copy link
Contributor Author

Greetings @skhaz,

I’m excited to share that we have just released conan-2.8, which now includes native support for the emcc compiler! This enhancement allows us to accurately model the built-in features of the Emscripten compiler.

In addition, this new repository will serve not only as a recipe index but also as a profile repository. You can check out the documentation available in my branch.

For example, take a look at the new wasm32 profile: https://github.com/perseoGI/conan-toolchains/blob/pgi/new/emsdk/conan_config/profiles/emsdk/wasm32.

Once this PR is merged, you can easily install these profiles by following the instructions in the README. However, if you'd like to test them right away, you can run the following command:

$ conan config install https://github.com/perseoGI/conan-toolchains.git -sf conan_config --args "-b pgi/new/emsdk"

If you're currently on version 2.18, please remember to update your profile with the new compiler settings:

emcc:
    # From https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md
    # Note: There is no ABI compatibility guarantee between versions
    version: [ANY]
    libcxx: [null, libstdc++, libstdc++11, libc++]
    threads: [null, posix, wasm_workers]
    cppstd: [null, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23, 26, gnu26]
    cstd: [null, 99, gnu99, 11, gnu11, 17, gnu17, 23, gnu23]

We’ve also added a new section on Web Assembly in our 2.18 documentation. While it hasn't been released yet, it should be available in about an hour. This section will provide a more detailed explanation of the new compiler model.

Thank you!

@perseoGI
Copy link
Contributor Author

@skhaz
https://docs.conan.io/2/examples/cross_build/emscripten.html
Here it is!

We will soon also add some examples, you could check them out here

@skhaz
Copy link

skhaz commented Jun 30, 2025

Thank you so much, I will give a try.

@skhaz
Copy link

skhaz commented Jul 1, 2025

Apologies for my ignorance, but how would the migration of my profile to WebAssembly work, as shown below?

$ cat ~/.conan2/profiles/webassembly
include(default)

[settings]
arch=wasm
os=Emscripten

[tool_requires]
*: emsdk/4.0.10

@perseoGI
Copy link
Contributor Author

perseoGI commented Jul 2, 2025

@skhaz no problem at all!

This would be a great wasm 32-bit profile:

[settings]
arch=wasm
build_type=Release
compiler=emcc
compiler.cppstd=17
compiler.libcxx=libc++
# Choose between both types of multithreading support (or none)
# compiler.threads=<posix|wasm_workers>
compiler.version=4.0.10
os=Emscripten

[tool_requires]
ninja/[*]
emsdk/4.0.10

[conf]
# Set Ninja as default generator as it is faster and will avoid Windows issues
tools.cmake.cmaketoolchain:generator=Ninja

Notice the usage of Ninja (if you are in windows, its crucial to avoid some compilation issues, and in general, Ninja is a better opcion over Makefile).

And the usage of compiler=emcc which is the new built-in native support compiler in conan.

In the docs you could find more information about other architectures such the experimental wasm64.
Or the explanation of why it is very important to declare the compirel.version. Remember in conan v2, the compiler.version setting is kind of syntactic sugar. It does not do anything but allowing conan to set some specific flags and what is most important, create different package IDs which will act as a result in incompatible binaries if merging two packages with different compiler version. This is crucial as emcc (the emscripten compiler) does not guarantee ANY ABI compatibility across versions!

I hope it helps!

include(default)

[conf]
tools.build.cross_building:can_run=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be in the .ci_profile in the emsdk recipe folder as this affects all recipes built by this script, and I dnt think can_run is True for all of them

"missing",
"--build-test",
f"{recipe_name}/*",
"--build-require",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable per recipe - it's only there to support the test package doing a tool_requires instead

---
## 🧰 Built-in Profiles

This repository includes several **pre-configured Conan profiles** designed to make toolchain setup effortless:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each "toolchain" should have a readme with tailored instructions - as I would expect this grow in the future.
I would refer to them as "reference" profiles - the ones we test, leaving it up to users to customise before installing. e.g. the "native" one still requires manual configuration, so I'm not sure that's effortless, there's still some use intervention needed in some instances.

we may consider having the profile .zip files as releases - so that a user can do conan config install https://github.com/xxxx/emsdk_profiles_1.0.zip or something like that - so that they get only what they need

@@ -0,0 +1,15 @@
[platform_tool_requires]
emsdk/4.0.10

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name "native" can be confusing because "native" usually means the "local cpu architecture".
I would probably go for another name.

This profile seems to assume that all these tools are discoverable in PATH, otherwise they won't work, other than perhaps in CMake.

Is there a case for adding a PATH in the [buildenv] section to point to the installation directory, in case it is not in the system PATH?

once again ,a README for this profiles may clarify these questions

generators = "CMakeToolchain", "VirtualBuildEnv"

def build_requirements(self):
self.tool_requires(self.tested_reference_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably have a test_package that is a regular requires and tests the post-conditions (e.g. checking emcc is called, etc)

and a separate, standalone "sample" project that is tested with the profiles in the profiles/emsdk folder instead. That way we test all the profiles

@skhaz
Copy link

skhaz commented Jul 2, 2025

Thank you so much @perseoGI.

Sorry bugging you again, I am just trying to help.

Do you know if do I need some extra setup?

ERROR: Package 'emsdk/4.0.10' not resolved: Unable to find 'emsdk/4.0.10' in remotes.

Ot it is not published yet?

cat ~/.conan2/profiles/default
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=17
os=Macos

[replace_tool_requires]
meson/*: meson/[*]
pkgconf/*: pkgconf/[*]

[tool_requires]
!cmake/*: cmake/[>=3 <4]

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
cat ~/.conan2/profiles/webassembly
include(default)

[tool_requires]
ninja/[*]
emsdk/4.0.10

[settings]
arch=wasm
build_type=Release
compiler=emcc
compiler.cppstd=17
compiler.libcxx=libc++
compiler.version=4.0.10
os=Emscripten

@jcar87
Copy link
Contributor

jcar87 commented Jul 2, 2025

Thank you so much @perseoGI.

Sorry bugging you again, I am just trying to help.

Do you know if do I need some extra setup?

ERROR: Package 'emsdk/4.0.10' not resolved: Unable to find 'emsdk/4.0.10' in remotes.

Ot it is not published yet?

cat ~/.conan2/profiles/default
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=17
os=Macos

[replace_tool_requires]
meson/*: meson/[*]
pkgconf/*: pkgconf/[*]

[tool_requires]
!cmake/*: cmake/[>=3 <4]

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
cat ~/.conan2/profiles/webassembly
include(default)

[tool_requires]
ninja/[*]
emsdk/4.0.10

[settings]
arch=wasm
build_type=Release
compiler=emcc
compiler.cppstd=17
compiler.libcxx=libc++
compiler.version=4.0.10
os=Emscripten

Hi @skhaz

For the time being - this new repo will be available as a local recipes index and not published to Conan Center - we want the focus of Conan Center to remain on libraries, and treat these (there will be more!) as a separate case - eventually we may make the recipes available in a remote.

You'd have to follow these instructions: https://github.com/perseoGI/conan-toolchains/tree/pgi/new/emsdk, however since it has not been merged, you have to do the following:

git clone https://github.com/perseoGI/conan-toolchains.git -b pgi/new/emsdk
conan remote add conan-toolchains ./conan-toolchains

For the recipe to be available.

@skhaz
Copy link

skhaz commented Jul 2, 2025

My bad, thank you so much.

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 this pull request may close these issues.

6 participants