Skip to content

Simplify clang vs clang++ selection process when compiling sources #20712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Nov 14, 2023

Base the choice solely on whether emcc or em++ was used on the command line. This means that the handling C vs C++ input files will now simply match that of the underlying compiler.

When running clang there is automatic language selection at the lower level such that that clang -c file.cc will run with -x c++ internally and clang -c file.c will run with -x c internally.

The situation with clang++ (and now em++) is a bit different in that running clang++ on .c input file not automatically use C mode and will generate a warning:

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

Previously we were hiding the warning but using clang internally even if the user ran with emc++.

@sbc100 sbc100 requested a review from RReverser November 14, 2023 19:09
@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 14, 2023

This helps with the next phase of #20577 which is to avoid running more than one clang subprocess when not needed.

@sbc100 sbc100 requested a review from kripken November 14, 2023 19:09
@sbc100 sbc100 force-pushed the simplify_compiler_selection branch 3 times, most recently from 16d97f6 to 875e31c Compare November 14, 2023 19:14
@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 14, 2023

Split out from #20713

@sbc100 sbc100 force-pushed the simplify_compiler_selection branch from 875e31c to 0439ebf Compare November 14, 2023 20:11
Base the choice solely on whether `emcc` or `em++` was used on the
command line.  This means that the handling C vs C++ input files will
now simply match that of the underlying compiler.

When running `clang` there is automatic language selection at the lower
level such that that `clang -c file.cc` will run with `-x c++`
internally and `clang -c file.c` will run with `-x c` internally.

The situation with `clang++` (and now `em++`) is a bit different in
that running `clang++` on `.c` input file not automatically use C mode
and will generate a warning:

```
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
```

Previously we were hiding the warning but using `clang` internally even
if the user ran with `emc++`.
@sbc100 sbc100 force-pushed the simplify_compiler_selection branch from 0439ebf to 3b6f62a Compare November 14, 2023 20:12
@sbc100 sbc100 merged commit 5022542 into emscripten-core:main Nov 14, 2023
@sbc100 sbc100 deleted the simplify_compiler_selection branch November 14, 2023 22:23
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