Skip to content

Disable C++ linking (DEFAULT_TO_CXX) by default - #27469

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:disable-default-to-cxx
Aug 3, 2026
Merged

Disable C++ linking (DEFAULT_TO_CXX) by default#27469
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:disable-default-to-cxx

Conversation

@sbc100

@sbc100 sbc100 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Disable DEFAULT_TO_CXX setting by default. This means that em++ is now required when linking C++ programs, matching the behavior of clang and gcc (clang++ and g++ respectively required).

This behavior was already the default under -sSTRICT.

The old behavior (allowing C++ even when run via emcc) is still available by adding -sDEFAULT_TO_CXX explicitly.

Fixes: #11121

@sbc100
sbc100 force-pushed the disable-default-to-cxx branch from c506ac6 to 5e7653f Compare July 31, 2026 22:08
@sbc100
sbc100 requested review from dschuff and kripken July 31, 2026 22:08
@sbc100

sbc100 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

I've been trying to make this happen basically forever, and I think we are finally in a place where it makes sense, especially since we can provide a nice error message.

@sbc100
sbc100 force-pushed the disable-default-to-cxx branch from 5e7653f to 9f54b3f Compare July 31, 2026 22:12

@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.

lgtm % comments

Comment thread src/settings.js Outdated
Comment thread tools/building.py
@sbc100
sbc100 force-pushed the disable-default-to-cxx branch 4 times, most recently from a1d49a3 to c2a19cd Compare August 2, 2026 23:45
Disable `DEFAULT_TO_CXX` setting by default.  This means that `em++` is
now required when linking C++ programs, matching the behavior of clang
and gcc (clang++ and g++ respectively required)

The old behavior (allowing C++ even when run via emcc) is still
available by adding `-sDEFAULT_TO_CXX` explicitly.

Fixes: emscripten-core#11121
@sbc100
sbc100 force-pushed the disable-default-to-cxx branch from c2a19cd to d05c129 Compare August 3, 2026 15:46
@sbc100
sbc100 merged commit 6ec69f5 into emscripten-core:main Aug 3, 2026
41 checks passed
@sbc100
sbc100 deleted the disable-default-to-cxx branch August 3, 2026 18:37
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.

Only link C++ libraries by default when run via em++ or when compiling a C++ file.

3 participants