Skip to content

Resolve libomp test errors#27073

Open
duerrbaby wants to merge 18 commits into
emscripten-core:mainfrom
duerrbaby:libomp
Open

Resolve libomp test errors#27073
duerrbaby wants to merge 18 commits into
emscripten-core:mainfrom
duerrbaby:libomp

Conversation

@duerrbaby

Copy link
Copy Markdown

Original PR here: #25937

@duerrbaby duerrbaby marked this pull request as ready for review June 9, 2026 08:07
@anutosh491

Copy link
Copy Markdown

Thanks a lot for looking into this. I'm looking forward to this for supporting openmp with clang-repl in the browser !

@duerrbaby

duerrbaby commented Jun 10, 2026

Copy link
Copy Markdown
Author

@anutosh491 tests are resolved. But I haven't tried it on my app yet.
EDIT: Confirmed to work on my side.

@duerrbaby

Copy link
Copy Markdown
Author

hi, @JAicewizard have you taken a look yet?

@duerrbaby duerrbaby changed the title !DO NOT MERGE! Test Libomp for new failures Resolve libomp test errors Jun 18, 2026
@duerrbaby

Copy link
Copy Markdown
Author

@sbc100 can you help to review?

@duerrbaby

Copy link
Copy Markdown
Author

@JAicewizard @sbc100 Hi again, does anyone have the time to review and hopefully merge this?
@anutosh491 and I would like to use this soon.

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we call the new directory system/lib/openmp to maybe the llvm directory name?

Can you update the PR title to better reflect what this is? Something like "Add openmp library from llvm" maybe?

Comment thread tools/system_libs.py
never_force = True
cflags = [
'-O3', '-DNDEBUG', '-pthread',
'-D_GNU_SOURCE', '-U_GLIBCXX_ASSERTIONS', '-D_GLIBCXX_NO_ASSERTIONS',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are there GLIBCXX macros here? We don't glibc anywhere so I'm surprised to see these.

Comment thread tools/system_libs.py
cflags = [
'-O3', '-DNDEBUG', '-pthread',
'-D_GNU_SOURCE', '-U_GLIBCXX_ASSERTIONS', '-D_GLIBCXX_NO_ASSERTIONS',
'-fno-exceptions', '-fno-rtti',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe both of these are the default so should not be needed.

Comment thread test/test_other.py
@@ -6245,6 +6245,7 @@ def test_modularize_instantiation_error(self):
# The flakiness of this test is very high on macOS so just disable it
# completely.
@no_mac('https://github.com/emscripten-core/emscripten/issues/19683')
@no_deno('Also flaky on Deno')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please revert this line. We could consider adding this, but it should be in a different PR

Comment thread test/test_core.py
}
"""
self.cflags += ["-fopenmp=libomp"]
self.do_run(src, "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you include the cflags in the do_run line. e.g. self.do_run(src, "", cflags=[...]).

Comment thread test/test_core.py
src = r"""
#include <omp.h>
int main(void) {
omp_get_max_threads();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What do we expect this to return?

Should we at least assert that its greater than zero?

os.mkdir("build")
os.chdir("build")

subprocess.call(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you use subprocess.run here and below instead of call.

)
subprocess.call("ninja")
subprocess.call(["env", "DESTDIR=.", "ninja", "install"])
os.chdir(cwd)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of calling os.chdir you can just pass cwd=build_dir to the tree subproceses

]
)
subprocess.call("ninja")
subprocess.call(["env", "DESTDIR=.", "ninja", "install"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe just pass --destdir=. to cmake above instead of using env here?\

Also, maybe we should not use the build dir as the install dir? That could be confusing.

shutil.copy2(
os.path.join(upstream_build_src, "kmp_i18n_default.inc"),
local_src,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe use a loop over a file list here?

@@ -0,0 +1,126 @@
#!/usr/bin/env python3
# Copyright 2023 The Emscripten Authors. All rights reserved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

2026

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.

4 participants