-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Greetings,
I am unsure if this is a bug or a huge misunderstand on how I am using emscripten so if it is the latter please forgive my ignorance. I am attempting to compile a project that I wrote in Qt and trying my hand at using Wasm to render the UI. I have followed the instructions on the wiki where I:
- Cloned the emsdk
git clone -b 5.0.2 <repo> --single-branch - ran
./emsdk install latest - ran
./emsdk activate latest - Added emsdk to my
.bashrcfile by addingsource "<location of emsdk_env.sh>
My project fully compiles with GCC 14.2.0 on both Rocky Linux and Ubuntu 24.04. However, trying to compile with emscripten I find features that should be in Clang are not properly found. These are std::chrono::current_zone and std::views::enumerate. I am unsure if this is a me issue or an issue with the compiler provided? I have pulled out two of the offenders and these are the compiler issues I am seeing.
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.2 (dc80f64)
Failing command line in full:
error: no member named 'enumerate' in namespace 'std::ranges::views'
55 | for(const auto& [index, entry] : std::views::enumerate(std::filesystem::directory_iterator{datasetPath}) )error: no member named 'current_zone' in namespace 'std::chrono'
13 | auto localTime = std::chrono::current_zone()->to_local(now);Full link command and output with -v appended:
emcc -std=c++23 test.cpp -v
/home/sailanarmo/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -std=c++23 -v -c test.cpp -o /tmp/emscripten_temp_846fy_g9/test.o
clang version 23.0.0git (https:/github.com/llvm/llvm-project 58f4da463e5b3cd3531cace17cc3f2d8d860964e)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/sailanarmo/emsdk/upstream/bin
(in-process)
"/home/sailanarmo/emsdk/upstream/bin/clang-23" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=/home/sailanarmo/AtlasImager -v -fcoverage-compilation-dir=/home/sailanarmo/AtlasImager -resource-dir /home/sailanarmo/emsdk/upstream/lib/clang/23 -D EMSCRIPTEN -isysroot /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /home/sailanarmo/emsdk/upstream/lib/clang/23/include -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include -std=c++23 -fdeprecated-macro -ferror-limit 19 -fmessage-length=197 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_846fy_g9/test.o -x c++ test.cpp
clang -cc1 version 23.0.0git based upon LLVM 23.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/compat
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
/home/sailanarmo/emsdk/upstream/lib/clang/23/include
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
test.cpp:13:33: error: no member named 'current_zone' in namespace 'std::chrono'
13 | auto localTime = std::chrono::current_zone()->to_local(now);
| ^~~~~~~~~~~~
1 error generated.
emcc: error: '/home/sailanarmo/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -std=c++23 -v -c test.cpp -o /tmp/emscripten_temp_846fy_g9/test.o' failed (returned 1)emcc -std=c++23 test.cpp -v
/home/sailanarmo/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -std=c++23 -v -c test.cpp -o /tmp/emscripten_temp_7vv33nqx/test.o
clang version 23.0.0git (https:/github.com/llvm/llvm-project 58f4da463e5b3cd3531cace17cc3f2d8d860964e)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/sailanarmo/emsdk/upstream/bin
(in-process)
"/home/sailanarmo/emsdk/upstream/bin/clang-23" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=/home/sailanarmo/AtlasImager -v -fcoverage-compilation-dir=/home/sailanarmo/AtlasImager -resource-dir /home/sailanarmo/emsdk/upstream/lib/clang/23 -D EMSCRIPTEN -isysroot /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /home/sailanarmo/emsdk/upstream/lib/clang/23/include -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include -std=c++23 -fdeprecated-macro -ferror-limit 19 -fmessage-length=197 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_7vv33nqx/test.o -x c++ test.cpp
clang -cc1 version 23.0.0git based upon LLVM 23.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/compat
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
/home/sailanarmo/emsdk/upstream/lib/clang/23/include
/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
test.cpp:13:46: error: no member named 'enumerate' in namespace 'std::ranges::views'
13 | for(const auto& [index, val] : std::views::enumerate(myVec))
| ^~~~~~~~~
test.cpp:13:56: error: use of undeclared identifier 'myVec'
13 | for(const auto& [index, val] : std::views::enumerate(myVec))
| ^~~~~
2 errors generated.
emcc: error: '/home/sailanarmo/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/home/sailanarmo/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -std=c++23 -v -c test.cpp -o /tmp/emscripten_temp_7vv33nqx/test.o' failed (returned 1)I can see that the -std=c++23 is being passed in and I am honestly unsure why this would be failing since the clang version is 23.0.0. According to Godbolt both of these should be in the main branch so I don't really understand what is failing here.
Code from test program:
#include <print>
#include <chrono>
#include <ranges>
auto main() -> int
{
auto now = std::chrono::system_clock::now();
auto localTime = std::chrono::current_zone()->to_local(now);
std::print("Current time: {}\n", localTime);
const auto myVec = std::vector{0,1,2,3,4};
for(const auto& [index, val] : std::views::enumerate(myVec))
std::println("Index: {} Value: {} ", index, val);
return 0;
}