Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ HARNESS_TESTS = \
scripts/tests/test_wasm_checker.py \
scripts/tests/test_wasm_module.py \
scripts/tests/test_wasm_quality.py \
scripts/tests/test_native_source_lto.py \
scripts/tests/test_wasi_inception.py \
scripts/tests/test_wasm_generators.py \
scripts/tests/test_machine_boundary.py \
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ Methods: [public programs](benchmarks/public/README.md) ([O0 and per-host result
- The [required C++11/14/17 profile](LANGUAGE_PROFILE.md) covers selected features. It is not full conformance to each edition.
- C++20 and C have partial support. The profile lists the selected C++20 features. The optional [PA38](pa38/README.md) compiles C sources in the `c17` and `gnu17` modes.
- The targets are Linux x86-64, Intel macOS and wasm32 (`wasm32-unknown-unknown` and `wasm32-wasip1`, [PA37](pa37/README.md)).
- `-Oz` and the LTO flags are experimental. `-Oz` optimizes for size.
`-flto` shares identical function bodies when linking Wasm.
`-flto=full` optimizes consecutive source inputs together on Wasm and
Linux x86-64. On Linux x86-64, use `-flto=full -c -o combined.o` to
produce one object for the host linker. Full LTO needs the source files
in the same command and can use more memory. Keep competing weak and
strong definitions in separate objects so the linker can select one.
- [Integrated assembly](pa29/README.md) is complete for its documented x86-64 profile. It is not a general assembler.
- The compiler has no C++ standard library of its own. Use the library that is installed on the host.
- The compiler can contain bugs.
Expand Down
15 changes: 13 additions & 2 deletions dev/cppgm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ SourceOutputInvocation parse_source_output_invocation(const vector<string>& args
{
invocation.optimizer.level = optimization_level(args[i]);
invocation.optimize_size = args[i] == "-Os" || args[i] == "-Oz";
invocation.optimizer.minimize_size = args[i] == "-Oz";
invocation.debug_optimization = args[i] == "-Og";
continue;
}
Expand Down Expand Up @@ -674,6 +675,7 @@ DriverInvocation parse_driver_invocation(const vector<string>& args)
bool compile_only = false;
bool preprocess_only = false;
bool explicit_outfile = false;
bool whole_source_lto = false;
vector<string> inputs;

for (size_t i = 0; i < args.size(); ++i)
Expand Down Expand Up @@ -708,6 +710,11 @@ DriverInvocation parse_driver_invocation(const vector<string>& args)
explicit_outfile = true;
continue;
}
if (args[i] == "-flto=full" || args[i] == "-flto" || args[i] == "-fno-lto")
{
whole_source_lto = args[i] == "-flto=full";
continue;
}
if (consume_preprocess_option(args, i) || consume_search_option(args, i) ||
consume_dependency_option(args, i) || consume_toolchain_option(args, i) || is_benign_driver_flag(args[i]))
{
Expand All @@ -728,7 +735,7 @@ DriverInvocation parse_driver_invocation(const vector<string>& args)
{
throw InvocationError("invalid usage");
}
if ((compile_only || preprocess_only) && explicit_outfile && inputs.size() != 1)
if ((preprocess_only || (compile_only && !whole_source_lto)) && explicit_outfile && inputs.size() != 1)
{
throw InvocationError("cannot specify -o when generating multiple output files");
}
Expand Down Expand Up @@ -1314,7 +1321,11 @@ int run_cppgm(const vector<string>& raw_args)
<< "this compiler's flags:\n"
" -S -emit-lowir write the LowIR that -c compiles, after the LowIR optimizer\n"
" (default output: <input>.lowir)\n"
" -fno-lowir-passes compile without the LowIR optimizer; the back end runs at the -O level\n";
" -fno-lowir-passes compile without the LowIR optimizer; the back end runs at the -O level\n"
" -Oz optimize for smaller code\n"
" -flto fold identical function bodies when linking Wasm objects\n"
" -flto=full optimize consecutive source inputs together when linking Wasm or x86-64 ELF\n"
" on x86-64 ELF, -c with -o writes one combined object\n";
return EXIT_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion dev/frontend_source_sets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ FRONTEND_OBJ_BASENAMES_cppgm += lowir/text_lexer lowir/text_parser lowir/text_pa
FRONTEND_OBJ_BASENAMES_cppgm += asm/registers

# Shared target dispatch and the wasm32 backend (PA37).
FRONTEND_PHASE_BASENAMES_wasm := wasm/bytes wasm/abi wasm/encoder wasm/mir_facts wasm/mir_writer wasm/local_cleanup wasm/local_lifetimes wasm/validation wasm/module wasm/exception_runtime wasm/exception_payload wasm/exception_plan wasm/select_exceptions wasm/selector wasm/object_places wasm/frame wasm/select_objects wasm/select_calls wasm/nonlocal_jumps wasm/select_varargs wasm/select_builtins wasm/control wasm/control_regions wasm/control_emission wasm/select_instructions wasm/select_atomics wasm/select_switch wasm/select_arithmetic wasm/select_vectors wasm/vector_permute wasm/vector_float wasm/vector_shift wasm/vector_compare wasm/vector_convert wasm/vector_horizontal wasm/vector_integer_math wasm/vector_reciprocal wasm/vector_reductions wasm/vector_carryless wasm/wide_helpers wasm/select_wide wasm/wide_locals wasm/select_wide_arithmetic wasm/select_wide_shift wasm/object_lowering wasm/object_aliases wasm/object_startup wasm/finalization wasm/runtime_inputs wasm/object_writer wasm/object_reader wasm/object_constants wasm/object_customs wasm/object_elements wasm/object_expression_validation wasm/object_features wasm/archive wasm/object_metadata wasm/object_validation wasm/object_code wasm/linker wasm/link_relocations wasm/link_globals wasm/link_data_exports wasm/link_output wasm/backend wasm/assembly_tokens wasm/assembly_parser wasm/assembly_instructions wasm/assembly_object
FRONTEND_PHASE_BASENAMES_wasm := wasm/bytes wasm/abi wasm/encoder wasm/mir_facts wasm/mir_writer wasm/local_cleanup wasm/local_lifetimes wasm/validation wasm/module wasm/exception_runtime wasm/exception_payload wasm/exception_plan wasm/select_exceptions wasm/selector wasm/object_places wasm/frame wasm/select_objects wasm/select_calls wasm/nonlocal_jumps wasm/select_varargs wasm/select_builtins wasm/control wasm/control_regions wasm/control_emission wasm/select_instructions wasm/select_atomics wasm/select_switch wasm/select_arithmetic wasm/select_vectors wasm/vector_permute wasm/vector_float wasm/vector_shift wasm/vector_compare wasm/vector_convert wasm/vector_horizontal wasm/vector_integer_math wasm/vector_reciprocal wasm/vector_reductions wasm/vector_carryless wasm/wide_helpers wasm/select_wide wasm/wide_locals wasm/select_wide_arithmetic wasm/select_wide_shift wasm/object_lowering wasm/object_aliases wasm/object_startup wasm/finalization wasm/runtime_inputs wasm/object_writer wasm/object_reader wasm/object_constants wasm/object_customs wasm/object_elements wasm/object_expression_validation wasm/object_features wasm/archive wasm/object_metadata wasm/object_validation wasm/object_code wasm/linker wasm/link_folding wasm/link_relocations wasm/link_globals wasm/link_data_exports wasm/link_output wasm/backend wasm/assembly_tokens wasm/assembly_parser wasm/assembly_instructions wasm/assembly_object
FRONTEND_OBJ_BASENAMES_lowir2native += lowir/text_writer lowir/assembly_writer lowir/local_names backend/compile $(FRONTEND_PHASE_BASENAMES_wasm) $(FRONTEND_PHASE_BASENAMES_opt)
# Object names use the shared UTF-8 decoder without the source lexer.
FRONTEND_OBJ_BASENAMES_lowir2native += support/unicode/utf8
Expand Down
5 changes: 4 additions & 1 deletion dev/src/backend/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ struct WasmLinkOptions
std::set<std::string> imports;
bool export_table = false;
bool export_constructors = false;
bool requested() const { return export_table || export_constructors || !imports.empty(); }
// Link-time identical code folding over resolved Wasm objects.
bool fold_functions = false;
bool compact_relocations = false;
bool requested() const { return export_table || export_constructors || fold_functions || !imports.empty(); }
};

struct Options
Expand Down
Loading
Loading