Open AlexApps99 opened 3 years ago
The cmath header that your project is using does work fine normally.. the likely issue is that somehow the wrong version of the C <math.h>
header is being include. Is there perhaps a file called math.h
in one of the include directories being used by your project:
-I/home/lxb/Desktop/dolphin/Source/Core -I/home/lxb/Desktop/dolphin/External/minizip
-I/home/lxb/Desktop/dolphin/Externals/mbedtls/include -I/home/lxb/Desktop/dolphin/Externals/libiconv-1.14/include
-I/home/lxb/Desktop/dolphin/Externals/picojson -I/home/lxb/Desktop/dolphin/build/Source/Core
-I/home/lxb/Desktop/dolphin/Externals/fmt/include -I/home/lxb/Desktop/dolphin/Externals/minizip/.
?
I looked through them all but came up empty
Well something odd is happing that is causing <cmath>
to not be include-able. Can you test the sanity of your install by compiling a simple file that just does #include <cmath>
.
If that works, the next thing to try would be to reproduce the failing command directly on the command line and then add -E
to produce and output file containing the pre-processed source code and then attach that output so we can help you figure out what is doing on.
The sanity check fails: https://gist.github.com/AlexApps99/ac64fa9a4de8ef9ecc82359c78dbfae9
I narrowed the command down to
em++ -isystem /home/lxb/Desktop/emsdk/upstream/emscripten/cache/sysroot/include -c /home/lxb/Desktop/dolphin/Source/Core/Common/Analytics.cpp
and the build still fails with the same reasons.
-E output here (very big): https://gist.github.com/AlexApps99/182c41a663bb70f121f41c8bb04b99c3
Given that test fails it seems there must be something wrong with your installation, but I have no idea what it could be.
Is there some reason you are passing that -isystem
flag? You certainly should not need to do that.
Is there some reason you are passing that
-isystem
flag? You certainly should not need to do that.
Not sure, I think it's a remnant of the CMake file I'm using. I checked without the -isystem
, and the sanity check did work
Clearly this is the problem, I will do what I can to remove it from the build system to see if that fixes it
Ah, I see what is happening. In C++ mode the math.h
header in include/c++/v1
should always be found first, it then includes the original libc header that lives in include/
via #include_next <math.h>
By passing -isystem /home/lxb/Desktop/emsdk/upstream/emscripten/cache/sysroot/include
you are putting the original C header first which breaks libc++.
That makes sense, thanks I'll be sure to remove the sysroot stuff and try again.
I am not entirely sure how to remove it, honestly. I'm using CMake, and I don't have any custom things that could create this error (to my knowledge)
The source is linked in my first comment in this issue, if anybody wants to have a look.
The -isystem
s seem to be generated in includes_CXX.rsp
and includes_C.rsp
files, still unsure how to affect these
I got the same problem when building opencv to WASM from sources. The -isystem
is breaking the build but i don't know how to get rid of it.
What version of emscripten are you all using? How are you running cmake? I can't see how the current version of emscripten would be adding that extra include.
Are you using any complex cmake logic? i.e. Does this problem reproduce for you with simple examples?
I am using the latest emscripten, and CMake with emcmake, and make with emmake The logic is fairly simple, and I have uploaded it in its entirety.
@sbc100 if you know anything about how to correct my issue, I would be very grateful. I apologize for my impatience, I just don't know how to debug or investigate the cause issue, it being a CMake one.
Can you give the exact sequence of commands you run in order produce a failing build based on the code in https://github.com/AlexApps99/dolphin/tree/lite?
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk/
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ../
git clone -b lite https://github.com/AlexApps99/dolphin.git
cd dolphin/
emcmake cmake -S . -B build
cd build/
emmake make
Or something like that
I also tried using CMake's Ninja generator, to no avail (the same errors)
I can repro locally too, but I can't find the place where that -isystem
is being injected.
AFAICT you should not see -isystem
appear in the rusuling build.ninja
file at all, but it is being using to add the sysroot include path for many object files.
I managed to work around the issues for now by doing a find and replace on build.ninja
, deleting all -isystem
s.
It seems to build, I am currently working on fixing all Emscripten incompatibilities, hopefully in the mean time the build system can be fixed proper.
sed -i 's/-isystem \/home\/foo\/Desktop\/emsdk\/upstream\/emscripten\/cache\/sysroot\/include//g' build/build.ninja
Source: AlexApps99/dolphin@lite Log: https://gist.github.com/AlexApps99/e229d54423c9173dc5d3fa111e104040#file-log-txt-L317-L451
Trying to port a project to Emscripten, I'm relatively new to it so I'm not really sure why this is failing.
5435 seemed similar, but I could not identify how to fix based on it.
I also found https://stackoverflow.com/q/58628377, but again, I don't know how it relates to my project.
I am happy to provide further information where needed.