emscripten-core / emscripten-core/emscripten

Embuilder can't set all linker flags usable by external ports

Open
#24,421 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Ports can choose which variant to build based on the flags passed to the `emcc` linker invocation. For example, many ports have `-mt` variants which build with `-pthreads`.

The mechanism by which `embuilder` supports these is called "variants", e.g. the `icu` port defines two ports, the default one named `icu` and a variant called `icu-mt`:

```
variants = {'icu-mt': {'PTHREADS': 1}}
```

However, external ports cannot use variants (as far as I know). I think there are three options here:
- Don't do anything, external ports need to use options (like Emdawnwebgpu's [`shared_memory`](https://dawn-review.googlesource.com/c/dawn/+/244075)) to do this.
- Come up with some `--port` syntax that allows specifying both a port file and the name of the variant to use.
- Add more options to `embuilder` so it can take linker flags like `-sSHARED_MEMORY`, `-sASSERTIONS`, etc. I'm somewhat partial to this one as it's more general, but it also is a bit of a can of worms.

---

> > [Emdawnwebgpu's `opt_level`] still needs to be an option if we want it to be possible to build both versions with `embuilder` (which seems to always set ASSERTIONS=1) - however if we want to fix this in `embuilder` instead, I would be fine removing the port option entirely; it would be nice to simplify it.
>
> Good point. We should add way to build debug flavored libraries using embuilder.

_Originally posted by @sbc100 in [#24260](https://github.com/emscripten-core/emscripten/issues/24260#issuecomment-2881648026)_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.