Skip to content

Enable clang builtin include path - #8766

Merged
sbc100 merged 1 commit into
incomingfrom
enable_clang_includes
Jun 18, 2019
Merged

sbc100 merged 1 commit into
incomingfrom
enable_clang_includes

Conversation

@sbc100

@sbc100 sbc100 commented Jun 7, 2019 •

Copy link
Copy Markdown
Collaborator

The -nostdlib argument to clang was previously preventing the
compiler specific include directory from being added.

@sbc100
sbc100 requested a review from kripken June 7, 2019 22:33
Comment thread tools/shared.py
]

c_opts = ['-nostdinc', '-Xclang', '-nobuiltininc', '-Xclang', '-nostdsysteminc']
c_opts = ['-Xclang', '-nostdsysteminc']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, I'm confused. Don't we need to disable the standard include dirs, so we can use our own stuff?

How are fastcomp and upstream different?

And what is nostdlib that is mentioned in the description, but I can't find in the codebase?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we want to include the lib/clang/9.0.0/include or lib/clang/6.0.1/include that comes with compiler while excluding all the other system include paths (e.g. /usr/include/..

-nostdinc acts as a kind of superset of -nobuiltininc and -nostdsysteminc so what we had here was redundant I think.

I believe we do want the builtin compiler headers, but not the system headers.

I was wrote about fastcomp behaving differently, it seems like the behaviour is that same.

An alternative approach here would be to add stdatomic.h and any other headers that live in the compiler's include directory to emscripten.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see. Sounds reasonable, assuming those compiler headers work properly and don't override any of our own?

How do I find them? I don't seem to have /usr[/local]/include/clang*, and in the llvm repo I see clang/include/ contains the clang internals?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These headers live in the lld and/or fastcomp install directories.

E.g.:

emsdk $ find -iname stdatomic.h
./upstream/5794/fastcomp/lib/clang/6.0.1/include/stdatomic.h
./upstream/5794/lib/clang/9.0.0/include/stdatomic.h

This pass is added at the very end of the include path, so they should act as a fallback for anything not found in musl.

e.g.: run emcc with -v to see the full include path:

nable-emscripten-sjlj -mllvm -disable-lsr -o test.o -x c test.c
clang -cc1 version 9.0.0 based upon LLVM 9.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include/wasm32-emscripten"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/include/libcxx
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libcxxabi/include
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/include/compat
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/include
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/include/libc
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc/musl/arch/emscripten
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/local/include
 /usr/local/google/home/sbc/dev/wasm/emscripten/system/include/SDL
 /usr/local/google/home/sbc/dev/wasm/llvm-build/lib/clang/9.0.0/include
End of search list.

@sbc100 sbc100 changed the title Enable clang builtin include path with llvm backend Enable clang builtin include path Jun 7, 2019
@sbc100
sbc100 force-pushed the enable_clang_includes branch from b86d45b to 1a2330c Compare June 10, 2019 13:57

@kripken kripken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see, thanks, lgtm!

@sbc100
sbc100 force-pushed the enable_clang_includes branch from 1a2330c to c469c16 Compare June 16, 2019 13:36
The `-nostdlib` argument to clang was previously preventing the
compiler specific include directory from being added, but this wasn't
effecting fastcomp in the same way.
@sbc100
sbc100 force-pushed the enable_clang_includes branch from c469c16 to f8a1873 Compare June 18, 2019 17:20
@sbc100
sbc100 merged commit 150b9d6 into incoming Jun 18, 2019
@sbc100
sbc100 deleted the enable_clang_includes branch June 18, 2019 17:21
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
…8766)

The `-nostdlib` argument to clang was previously preventing the
compiler specific include directory from being added, but this wasn't
effecting fastcomp in the same way.
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.

2 participants