diff --git a/.circleci/config.yml b/.circleci/config.yml index f0b37bcadc5dd..47b4444cb8357 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -981,6 +981,7 @@ jobs: # clang can compile but not link in the current setup, see # https://github.com/emscripten-core/emscripten/pull/11382#pullrequestreview-428902638 EMTEST_LACKS_NATIVE_CLANG: "1" + EMTEST_BUILD_VERBOSE: "2" EMTEST_SKIP_V8: "1" EMTEST_SKIP_EH: "1" EMTEST_SKIP_WASM64: "1" @@ -1005,12 +1006,7 @@ jobs: python: "$EMSDK_PYTHON" - run-tests: title: "crossplatform tests" - test_targets: "--crossplatform-only" - - upload-test-results - # Run a single websockify-based test to ensure it works on windows. - - run-tests: - title: "sockets.test_nodejs_sockets_echo*" - test_targets: "sockets.test_nodejs_sockets_echo*" + test_targets: "other.test_cmake_cxx20" - upload-test-results test-mac-arm64: @@ -1039,59 +1035,4 @@ jobs: workflows: build-test: jobs: - - ruff - - mypy - - eslint - - build-docs - - build-linux - - test-sanity: - requires: - - build-linux - - test-posixtest: - requires: - - build-linux - - test-core0: - requires: - - build-linux - - test-core2: - requires: - - build-linux - - test-core3: - requires: - - build-linux - - test-wasm64: - requires: - - build-linux - - test-wasm64-4gb: - requires: - - build-linux - - test-wasm2js1: - requires: - - build-linux - - test-other: - requires: - - build-linux - - test-browser-chrome: - requires: - - build-linux - - test-browser-chrome-2gb: - requires: - - build-linux - - test-browser-chrome-wasm64: - requires: - - build-linux - - test-browser-chrome-wasm64-4gb: - requires: - - build-linux - - test-browser-firefox: - requires: - - build-linux - - test-browser-firefox-wasm64 - - test-sockets-chrome: - requires: - - build-linux - - test-jsc - - test-spidermonkey - - test-node-compat - test-windows - - test-mac-arm64 diff --git a/cmake/Modules/Platform/Emscripten.cmake b/cmake/Modules/Platform/Emscripten.cmake index b8a18defe1078..f3e3d9262d944 100644 --- a/cmake/Modules/Platform/Emscripten.cmake +++ b/cmake/Modules/Platform/Emscripten.cmake @@ -93,6 +93,7 @@ set(CMAKE_C_COMPILER_AR "${CMAKE_AR}") set(CMAKE_CXX_COMPILER_AR "${CMAKE_AR}") set(CMAKE_C_COMPILER_RANLIB "${CMAKE_RANLIB}") set(CMAKE_CXX_COMPILER_RANLIB "${CMAKE_RANLIB}") +set(CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS "${EMSCRIPTEN_ROOT_PATH}/emscan-deps") # Capture the Emscripten version to EMSCRIPTEN_VERSION variable. if (NOT EMSCRIPTEN_VERSION) diff --git a/emscan-deps b/emscan-deps new file mode 100755 index 0000000000000..eef0f00c6730f --- /dev/null +++ b/emscan-deps @@ -0,0 +1,35 @@ +#!/bin/sh +# Copyright 2020 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. +# +# Entry point for running python scripts on UNIX systems. +# +# Automatically generated by `create_entry_points.py`; DO NOT EDIT. +# +# To make modifications to this file, edit `tools/run_python.sh` and then run +# `tools/maint/create_entry_points.py` + +# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal +# of cpython used in cross compilation via setup.py. +unset _PYTHON_SYSCONFIGDATA_NAME + +if [ -z "$PYTHON" ]; then + PYTHON=$EMSDK_PYTHON +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(command -v python3 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(command -v python 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + echo 'unable to find python in $PATH' + exit 1 +fi + +exec "$PYTHON" -E "$0.py" "$@" diff --git a/emscan-deps.bat b/emscan-deps.bat new file mode 100644 index 0000000000000..83edd646f7918 --- /dev/null +++ b/emscan-deps.bat @@ -0,0 +1,86 @@ +:: Entry point for running python scripts on windows systems. +:: +:: Automatically generated by `create_entry_points.py`; DO NOT EDIT. +:: +:: To make modifications to this file, edit `tools/run_python.bat` and then run +:: `tools/maint/create_entry_points.py` + +:: N.b. In Windows .bat scripts, the ':' character cannot appear inside any if () blocks, +:: or there will be a parsing error. + +:: All env. vars specified in this file are to be local only to this script. +@setlocal +:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal +:: of cpython used in cross compilation via setup.py. +@set _PYTHON_SYSCONFIGDATA_NAME= +@set EM_PY=%EMSDK_PYTHON% +@if "%EM_PY%"=="" ( + set EM_PY=python +) + +:: Work around Windows bug https://github.com/microsoft/terminal/issues/15212 : If this +:: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and +:: %~dp0 expansions will not work. +:: So first try if %~dp0 might work, and if not, manually look up this script from PATH. +@if exist "%~f0" ( + set MYDIR=%~dp0 + goto FOUND_MYDIR +) +@for %%I in (%~n0.bat) do ( + @if exist %%~$PATH:I ( + set MYDIR=%%~dp$PATH:I + ) else ( + echo Fatal Error! Due to a Windows bug, we are unable to locate the path to %~n0.bat. + echo To help this issue, try removing unnecessary quotes in the invocation of emcc, + echo or add Emscripten directory to PATH. + echo See github.com/microsoft/terminal/issues/15212 and + echo github.com/emscripten-core/emscripten/issues/19207 for more details. + ) +) +:FOUND_MYDIR + +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + goto NORMAL + ) else ( + goto NORMAL_EXIT + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + goto MUTE_STDIN + ) else ( + goto MUTE_STDIN_EXIT + ) +) + +:NORMAL_EXIT +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL +@exit /b %ERRORLEVEL% + +:MUTE_STDIN_EXIT +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* diff --git a/emscan-deps.py b/emscan-deps.py new file mode 100755 index 0000000000000..001ac158f6f5b --- /dev/null +++ b/emscan-deps.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# Copyright 2025 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. + +"""emscan-deps - clang-scan-deps helper script + +This script acts as a frontend replacement for clang-scan-deps. +""" + +import sys +from tools import shared, cache + +args = sys.argv[1:] +args.append('--sysroot=' + cache.get_sysroot(absolute=True)) +sys.stderr.write('SCANDEPS: ' + str(args) + '\n') +shared.exec_process([shared.CLANG_SCAN_DEPS] + args) diff --git a/test/cmake/cxx20/CMakeLists.txt b/test/cmake/cxx20/CMakeLists.txt new file mode 100644 index 0000000000000..7e457529c5d5a --- /dev/null +++ b/test/cmake/cxx20/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.5...3.28) + +project(cxx20test) + +set(CMAKE_CXX_STANDARD 20) + +add_executable(cxx20test main.cpp) diff --git a/test/cmake/cxx20/main.cpp b/test/cmake/cxx20/main.cpp new file mode 100644 index 0000000000000..987442e18a5ce --- /dev/null +++ b/test/cmake/cxx20/main.cpp @@ -0,0 +1,13 @@ +// Copyright 2025 The Emscripten Authors. All rights reserved. +// Emscripten is available under two separate licenses, the MIT license and the +// University of Illinois/NCSA Open Source License. Both these licenses can be +// found in the LICENSE file. + +#include + +class Test {}; // This will fail in C mode + +int main() { + printf("hello, world!\n"); + return 0; +} diff --git a/test/cmake/cxx20/out.txt b/test/cmake/cxx20/out.txt new file mode 100644 index 0000000000000..270c611ee72c5 --- /dev/null +++ b/test/cmake/cxx20/out.txt @@ -0,0 +1 @@ +hello, world! diff --git a/test/test_other.py b/test/test_other.py index 3ff1aa33aa469..b4d6b106827b1 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -906,6 +906,7 @@ def test_emstrip(self): 'whole_archive': ('whole_archive', 'whole.js', []), 'stdproperty': ('stdproperty', 'helloworld.js', []), 'post_build': ('post_build', 'hello.js', []), + 'cxx20': ('cxx20', 'cxx20test.js', []), }) def test_cmake(self, test_dir, output_file, cmake_args): if test_dir == 'whole_archive' and 'EMTEST_SKIP_NEW_CMAKE' in os.environ: @@ -956,7 +957,7 @@ def test_cmake(self, test_dir, output_file, cmake_args): # Run through node, if CMake produced a .js file. if output_file.endswith('.js'): ret = self.run_js(output_file) - self.assertTextDataIdentical(read_file(cmakelistsdir + '/out.txt').strip(), ret.strip()) + self.assertFileContents(os.path.join(cmakelistsdir, 'out.txt'), ret) if test_dir == 'post_build': ret = self.run_process(['ctest'], env=env) diff --git a/tools/maint/create_entry_points.py b/tools/maint/create_entry_points.py index 03ad860e3983b..7d9d0b0da16ca 100755 --- a/tools/maint/create_entry_points.py +++ b/tools/maint/create_entry_points.py @@ -43,6 +43,7 @@ emnm emstrip emsymbolizer +emscan-deps system/bin/sdl-config system/bin/sdl2-config tools/file_packager diff --git a/tools/shared.py b/tools/shared.py index 8e2716cf17822..6c7a615f5e891 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -790,6 +790,7 @@ class OFormat(Enum): CLANG_CC = os.path.expanduser(build_clang_tool_path(exe_suffix('clang'))) CLANG_CXX = os.path.expanduser(build_clang_tool_path(exe_suffix('clang++'))) +CLANG_SCAN_DEPS = build_llvm_tool_path(exe_suffix('clang-scan-deps')) LLVM_AR = build_llvm_tool_path(exe_suffix('llvm-ar')) LLVM_DWP = build_llvm_tool_path(exe_suffix('llvm-dwp')) LLVM_RANLIB = build_llvm_tool_path(exe_suffix('llvm-ranlib'))