-
Notifications
You must be signed in to change notification settings - Fork 3.4k
emscripten_strict #4665
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
emscripten_strict #4665
Changes from all commits
6a148a2
8e3bf5b
b8e9130
4e1eabe
f2d975a
1b3fe42
72c97d1
381eca8
af265a5
1b4e784
11e4634
12d47b0
815a35b
022c4db
08b70e5
267c4ee
8455fba
9b727e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,7 +250,11 @@ def filter_emscripten_options(argv): | |
if compiler == shared.EMCC: compiler = [shared.PYTHON, shared.EMCC] | ||
else: compiler = [compiler] | ||
cmd = compiler + list(filter_emscripten_options(sys.argv[1:])) | ||
if not use_js: cmd += shared.EMSDK_OPTS + ['-D__EMSCRIPTEN__', '-DEMSCRIPTEN'] | ||
if not use_js: | ||
cmd += shared.EMSDK_OPTS + ['-D__EMSCRIPTEN__'] | ||
# The preprocessor define EMSCRIPTEN is deprecated. Don't pass it to code in strict mode. Code should use the define __EMSCRIPTEN__ instead. | ||
if not shared.Settings.STRICT: | ||
cmd += ['-DEMSCRIPTEN'] | ||
if use_js: cmd += ['-s', 'ERROR_ON_UNDEFINED_SYMBOLS=1'] # configure tests should fail when an undefined symbol exists | ||
|
||
logging.debug('just configuring: ' + ' '.join(cmd)) | ||
|
@@ -918,6 +922,29 @@ def detect_fixed_language_mode(args): | |
if separate_asm: | ||
shared.Settings.SEPARATE_ASM = os.path.basename(asm_target) | ||
|
||
if 'EMCC_STRICT' in os.environ: | ||
shared.Settings.STRICT = os.environ.get('EMCC_STRICT') != '0' | ||
|
||
# Libraries are searched before settings_changes are applied, so apply the value for STRICT and ERROR_ON_MISSING_LIBRARIES from | ||
# command line already now. | ||
|
||
def get_last_setting_change(setting): | ||
return ([None] + filter(lambda x: x.startswith(setting + '='), settings_changes))[-1] | ||
|
||
strict_cmdline = get_last_setting_change('STRICT') | ||
if strict_cmdline: | ||
shared.Settings.STRICT = int(strict_cmdline[len('STRICT='):]) | ||
|
||
if shared.Settings.STRICT: | ||
shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS = 1 | ||
shared.Settings.ERROR_ON_MISSING_LIBRARIES = 1 | ||
|
||
error_on_missing_libraries_cmdline = get_last_setting_change('ERROR_ON_MISSING_LIBRARIES') | ||
if error_on_missing_libraries_cmdline: | ||
shared.Settings.ERROR_ON_MISSING_LIBRARIES = int(error_on_missing_libraries_cmdline[len('ERROR_ON_MISSING_LIBRARIES='):]) | ||
|
||
system_js_libraries = [] | ||
|
||
# Find library files | ||
for i, lib in libs: | ||
logging.debug('looking for library "%s"', lib) | ||
|
@@ -934,8 +961,13 @@ def detect_fixed_language_mode(args): | |
break | ||
if found: break | ||
if found: break | ||
if not found and lib not in ['GL', 'GLU', 'glut', 'm', 'c', 'SDL', 'stdc++', 'pthread']: # whitelist our default libraries | ||
logging.warning('emcc: cannot find library "%s"', lib) | ||
if not found: | ||
system_js_libraries += shared.Building.path_to_system_js_libraries(lib) | ||
|
||
# Certain linker flags imply some link libraries to be pulled in by default. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i still feel these lines are nicer in something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe leave that for a possible followup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, added a function for that in |
||
system_js_libraries += shared.Building.path_to_system_js_libraries_for_settings(settings_changes) | ||
|
||
settings_changes.append('SYSTEM_JS_LIBRARIES="' + ','.join(system_js_libraries) + '"') | ||
|
||
# If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so | ||
# ignore dynamic linking, since multiple dynamic linkings can interfere with each other | ||
|
@@ -999,6 +1031,15 @@ def check(input_file): | |
if shared.get_llvm_target() == shared.WASM_TARGET: | ||
shared.Settings.WASM_BACKEND = 1 | ||
|
||
if not shared.Settings.STRICT: | ||
# The preprocessor define EMSCRIPTEN is deprecated. Don't pass it to code in strict mode. Code should use the define __EMSCRIPTEN__ instead. | ||
shared.COMPILER_OPTS += ['-DEMSCRIPTEN'] | ||
|
||
# The system include path system/include/emscripten/ is deprecated, i.e. instead of #include <emscripten.h>, one should pass in #include <emscripten/emscripten.h>. | ||
# This path is not available in Emscripten strict mode. | ||
if shared.USE_EMSDK: | ||
shared.C_INCLUDE_PATHS += [shared.path_from_root('system', 'include', 'emscripten')] | ||
|
||
# Use settings | ||
|
||
try: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -487,6 +487,10 @@ var LINKABLE = 0; // If set to 1, this file can be linked with others, either as | |
// LINKABLE of 0 is very useful in that we can reduce the size of the | ||
// generated code very significantly, by removing everything not actually used. | ||
|
||
var STRICT = 0; // Emscripten 'strict' build mode: Drop supporting any deprecated build options. | ||
// Set the environment variable EMCC_STRICT=1 or pass -s STRICT=1 | ||
// to test that a codebase builds nicely in forward compatible manner. | ||
|
||
var WARN_ON_UNDEFINED_SYMBOLS = 1; // If set to 1, we will warn on any undefined symbols that | ||
// are not resolved by the library_*.js files. Note that | ||
// it is common in large projects to | ||
|
@@ -501,6 +505,22 @@ var WARN_ON_UNDEFINED_SYMBOLS = 1; // If set to 1, we will warn on any undefined | |
var ERROR_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will give a compile-time error on any | ||
// undefined symbols (see WARN_ON_UNDEFINED_SYMBOLS). | ||
|
||
// The default value for this is currently 0, but will be | ||
// transitioned to 1 in the future. To keep relying on | ||
// building with -s ERROR_ON_UNDEFINED_SYMBOLS=0 setting, | ||
// prefer to set that option explicitly in your build system. | ||
|
||
var ERROR_ON_MISSING_LIBRARIES = 0; // If set to 1, any -lfoo directives pointing to nonexisting | ||
// library files will issue a linker error. | ||
|
||
// The default value for this is currently 0, but will be | ||
// transitioned to 1 in the future. To keep relying on | ||
// building with -s ERROR_ON_MISSING_LIBRARIES=0 setting, | ||
// prefer to set that option explicitly in your build system. | ||
|
||
var SYSTEM_JS_LIBRARIES = []; // Specifies a list of Emscripten-provided JS libraries to link against. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although for people using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that might be true, though not sure if I want to change this right now at least, there doesn't seem to be any tests for the |
||
// (internal, use -lfoo or -lfoo.js to link to Emscripten system JS libraries) | ||
|
||
var SMALL_XHR_CHUNKS = 0; // Use small chunk size for binary synchronous XHR's in Web Workers. | ||
// Used for testing. | ||
// See test_chunked_synchronous_xhr in runner.py and library.js. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "emscripten/emscripten.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this happens after the code above for
-DEMSCRIPTEN
, so it seems it would only work for the setting and not the environment var?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or wait, is the above for the configure stuff? then it's ok.