emscripten-core / emscripten-core/emscripten

Different -Wpoison-system-directories behavior between macOS x86_64 and macOS arm64

Ouverte
#14,031 22 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
27.6k
Forks
3.6k
Merge moyen
1 j 14 h
PR mergées (30 j)
125

Description

I have an Intel Mac and a M1 Mac, both with the same OS version (macOS 11.3), both with the same version of `emsdk` (2.0.18). `em++` with `-Wpoison-system-directories` behaves differently between the two. With the following simple source code:

```
#include

int main(int argc, const char* argv[])
{
printf("Hello world!\n");
return 0;
}
```

And the following compiler invocation:

`/usr/local/opt/emsdk/upstream/emscripten/em++ -Wpoison-system-directories a.cpp`

I get no warnings on the Intel Mac, but I get the following warning on the M1 Mac:

```
warning: include location '/usr/local/include' is unsafe for cross-compilation [-Wpoison-system-directories]
1 warning generated.
```

Looking at the verbose (`-v`) output on the two machines, the only differences are that `-I/usr/local/include` is added on the M1 Mac, and the version of `node` differs between the two (`/usr/local/opt/emsdk/node/14.15.5_64bit/bin/node` on the M1, `/usr/local/opt/emsdk/node/12.18.1_64bit/bin/node` on the Intel).

Here is the full verbose output on the M1 Mac:

```
"/usr/local/opt/emsdk/upstream/bin/clang++" -target wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=18 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -v -Wpoison-system-directories a.cpp -c -o /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/emscripten_temp_kjqhgwwc/a_0.o
clang version 13.0.0 (/opt/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project 94340dd5bb23fb7c4bc7d91d5ac0608eb25660a8)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/local/opt/emsdk/upstream/bin
(in-process)
"/usr/local/opt/emsdk/upstream/bin/clang-13" -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name a.cpp -mrelocation-model static -mframe-pointer=none -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility hidden -debugger-tuning=gdb -target-linker-version 609.8 -v -fcoverage-compilation-dir=/Users/schofield/Downloads/tmp -resource-dir /usr/local/opt/emsdk/upstream/lib/clang/13.0.0 -D EMSCRIPTEN -D __EMSCRIPTEN_major__=2 -D __EMSCRIPTEN_minor__=0 -D __EMSCRIPTEN_tiny__=18 -D _LIBCPP_ABI_VERSION=2 -D unix -D __unix -D __unix__ -isysroot /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot -I/usr/local/include -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /usr/local/opt/emsdk/upstream/lib/clang/13.0.0/include -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -Wpoison-system-directories -fdeprecated-macro -fdebug-compilation-dir=/Users/schofield/Downloads/tmp -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/SDL -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/emscripten_temp_kjqhgwwc/a_0.o -x c++ a.cpp
clang -cc1 version 13.0.0 based upon LLVM 13.0.0git default target x86_64-apple-darwin20.4.0
warning: include location '/usr/local/include' is unsafe for cross-compilation [-Wpoison-system-directories]
ignoring nonexistent directory "/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/SDL
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/compat
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
/usr/local/opt/emsdk/upstream/lib/clang/13.0.0/include
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
1 warning generated.
"/usr/local/opt/emsdk/upstream/bin/wasm-ld" -o a.out.wasm /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/emscripten_temp_kjqhgwwc/a_0.o -L/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libgl.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libal.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libhtml5.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc++-noexcept.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc++abi-noexcept.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libdlmalloc.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc_rt_wasm.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --strip-debug --export main --export emscripten_stack_get_end --export emscripten_stack_get_free --export emscripten_stack_init --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export fflush --export __errno_location --export-table --export __start_em_asm --export __stop_em_asm -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024
"/usr/local/opt/emsdk/upstream/bin/wasm-emscripten-finalize" --minimize-wasm-changes --dyncalls-i64 a.out.wasm -o a.out.wasm --detect-features
"/usr/local/opt/emsdk/node/14.15.5_64bit/bin/node" /usr/local/opt/emsdk/upstream/emscripten/src/compiler.js /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/tmp3nc0jxaa.txt
"/usr/local/opt/emsdk/upstream/bin/llvm-objcopy" a.out.wasm a.out.wasm --remove-section=.debug* --remove-section=producers
```

Here is the full verbose output on the Intel Mac:

```
"/usr/local/opt/emsdk/upstream/bin/clang++" -target wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=18 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -v -Wpoison-system-directories a.cpp -c -o /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/emscripten_temp_q25h2mff/a_0.o
clang version 13.0.0 (/opt/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project 94340dd5bb23fb7c4bc7d91d5ac0608eb25660a8)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/local/opt/emsdk/upstream/bin
(in-process)
"/usr/local/opt/emsdk/upstream/bin/clang-13" -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name a.cpp -mrelocation-model static -mframe-pointer=none -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility hidden -debugger-tuning=gdb -target-linker-version 609.8 -v -fcoverage-compilation-dir=/Users/schofield/Downloads/tmp -resource-dir /usr/local/opt/emsdk/upstream/lib/clang/13.0.0 -D EMSCRIPTEN -D __EMSCRIPTEN_major__=2 -D __EMSCRIPTEN_minor__=0 -D __EMSCRIPTEN_tiny__=18 -D _LIBCPP_ABI_VERSION=2 -D unix -D __unix -D __unix__ -isysroot /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /usr/local/opt/emsdk/upstream/lib/clang/13.0.0/include -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -Wpoison-system-directories -fdeprecated-macro -fdebug-compilation-dir=/Users/schofield/Downloads/tmp -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/SDL -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/emscripten_temp_q25h2mff/a_0.o -x c++ a.cpp
clang -cc1 version 13.0.0 based upon LLVM 13.0.0git default target x86_64-apple-darwin20.4.0
ignoring nonexistent directory "/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/SDL
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/compat
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
/usr/local/opt/emsdk/upstream/lib/clang/13.0.0/include
/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
"/usr/local/opt/emsdk/upstream/bin/wasm-ld" -o a.out.wasm /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/emscripten_temp_q25h2mff/a_0.o -L/usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libgl.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libal.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libhtml5.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc++-noexcept.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc++abi-noexcept.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libdlmalloc.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc_rt_wasm.a /usr/local/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --strip-debug --export main --export emscripten_stack_get_end --export emscripten_stack_get_free --export emscripten_stack_init --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export fflush --export __errno_location --export-table --export __start_em_asm --export __stop_em_asm -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024
"/usr/local/opt/emsdk/upstream/bin/wasm-emscripten-finalize" --minimize-wasm-changes --dyncalls-i64 a.out.wasm -o a.out.wasm --detect-features
"/usr/local/opt/emsdk/node/12.18.1_64bit/bin/node" /usr/local/opt/emsdk/upstream/emscripten/src/compiler.js /var/folders/0f/lpnk71n94dg4f4yqv0zxwz7c0000gn/T/tmpqw8e916y.txt
"/usr/local/opt/emsdk/upstream/bin/llvm-objcopy" a.out.wasm a.out.wasm --remove-section=.debug* --remove-section=producers
```

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Reproduisez le problème avec la commande em++ indiquée et comparez sa sortie -v sur macOS x86_64 et arm64, en vous concentrant sur l’entrée inattendue /usr/local/include. Suivez la manière dont em++ invoque clang++ et compiler.js, puis vérifiez que des environnements équivalents produisent soit le même comportement d’avertissement, soit que la différence prévue est documentée et couverte par un test de régression.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp, wasm
Domaine
compilers
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.