Windows quoting behavior.
--
-[#config_run_second_cpp]
-*run_second_cpp* (*CCACHE_CPP2* or *CCACHE_NOCPP2*, see _<<Boolean values>>_ above)::
-
- If true, ccache will first run the preprocessor to preprocess the source
- code (see _<<The preprocessor mode>>_) and then on a cache miss run the
- compiler on the source code to get hold of the object file. This is the
- default.
-+
-If false, ccache will first run preprocessor to preprocess the source code and
-then on a cache miss run the compiler on the _preprocessed source code_ instead
-of the original source code. This makes cache misses slightly faster since the
-source code only has to be preprocessed once. The downside is that some
-compilers won't produce the same result (for instance diagnostics warnings)
-when compiling preprocessed source code.
-+
-A solution to the above mentioned downside is to set *run_second_cpp* to false
-and pass `-fdirectives-only` (for GCC) or `-frewrite-includes` (for Clang) to
-the compiler. This will cause the compiler to leave the macros and other
-preprocessor information, and only process the *#include* directives. When run
-in this way, the preprocessor arguments will be passed to the compiler since it
-still has to do _some_ preprocessing (like macros).
-+
-This option is ignored with MSVC, as there is no way to make it compile without
-preprocessing first.
-
[#config_sloppiness]
*sloppiness* (*CCACHE_SLOPPINESS*)::
The depend mode will be disabled if any of the following holds:
* <<config_depend_mode,*depend_mode*>> is false.
-* <<config_run_second_cpp,*run_second_cpp*>> is false.
* The compiler is not generating dependencies using `-MD` or `-MMD` (for MSVC,
`/showIncludes` is added automatically if not specified by the user).
#! /usr/bin/env python3
#
-# Copyright (C) 2010-2020 Joel Rosdahl and other contributors
+# Copyright (C) 2010-2025 Joel Rosdahl and other contributors
#
# See doc/AUTHORS.adoc for a complete list of contributors.
#
environment["CCACHE_HARDLINK"] = "1"
if options.no_compression:
environment["CCACHE_NOCOMPRESS"] = "1"
- if options.no_cpp2:
- environment["CCACHE_NOCPP2"] = "1"
if options.no_stats:
environment["CCACHE_NOSTATS"] = "1"
),
type="int",
)
- op.add_option(
- "--no-cpp2", help="compile preprocessed output", action="store_true"
- )
op.add_option(
"--no-stats", help="don't write statistics", action="store_true"
)
print("Compression level:", options.compression_level or "default")
print("File cloning:", on_off(options.file_clone))
print("Hard linking:", on_off(options.hardlink))
- print("No cpp2:", on_off(options.no_cpp2))
print("No stats:", on_off(options.no_stats))
tmp_dir = "%s/perfdir.%d" % (abspath(options.directory), getpid())
bool found_valid_Fp = false;
bool found_syntax_only = false;
ColorDiagnostics color_diagnostics = ColorDiagnostics::automatic;
- bool found_directives_only = false;
- bool found_rewrite_includes = false;
std::unordered_map<std::string, std::vector<std::string>> xarch_args;
bool found_mf_opt = false;
bool found_wp_md_or_mmd_opt = false;
std::vector<fs::path> input_files;
// common_args contains all original arguments except:
- // * those that never should be passed to the preprocessor,
- // * those that only should be passed to the preprocessor (if run_second_cpp
- // is false), and
+ // * those that never should be passed to the preprocessor, and
// * dependency options (like -MD and friends).
Args common_args;
- // cpp_args contains arguments that were not added to common_args, i.e. those
- // that should only be passed to the preprocessor if run_second_cpp is false.
- // If run_second_cpp is true, they will be passed to the compiler as well.
+ // cpp_args contains arguments that were not added to common_args.
Args cpp_args;
// dep_args contains dependency options like -MD. They are only passed to the
}
++i;
args_info.arch_args.emplace_back(args[i]);
- if (args_info.arch_args.size() == 2) {
- config.set_run_second_cpp(true);
- }
return Statistic::none;
}
// Avoid passing -P to the preprocessor since it removes preprocessor
// information we need.
state.compiler_only_args.push_back(args[i]);
- LOG("{} used; not compiling preprocessed code", args[i]);
- config.set_run_second_cpp(true);
return Statistic::none;
}
}
}
- // GCC
- if (arg == "-fdirectives-only") {
- state.found_directives_only = true;
- return Statistic::none;
- }
-
- // Clang
- if (arg == "-frewrite-includes") {
- state.found_rewrite_includes = true;
- return Statistic::none;
- }
-
if (arg == "-fno-pch-timestamp") {
args_info.fno_pch_timestamp = true;
state.common_args.push_back(args[i]);
return tl::unexpected(*argument_error);
}
- if (state.generating_debuginfo_level_3 && !config.run_second_cpp()) {
- // Debug level 3 makes line number information incorrect when compiling
- // preprocessed code.
- LOG_RAW("Generating debug info level 3; not compiling preprocessed code");
- config.set_run_second_cpp(true);
- }
-
-#ifdef __APPLE__
- // Newer Clang versions on macOS are known to produce different debug
- // information when compiling preprocessed code.
- if (args_info.generating_debuginfo && !config.run_second_cpp()) {
- LOG_RAW("Generating debug info; not compiling preprocessed code");
- config.set_run_second_cpp(true);
- }
-#endif
-
if (state.found_pch || state.found_fpch_preprocess) {
args_info.using_precompiled_header = true;
if (!(config.sloppiness().contains(core::Sloppy::time_macros))) {
}
}
- if (args_info.profile_generate && !config.run_second_cpp()) {
- LOG_RAW(
- "Generating profiling information; not compiling preprocessed code");
- config.set_run_second_cpp(true);
- }
-
if (args_info.profile_path.empty()) {
args_info.profile_path = ctx.apparent_cwd;
}
args_info.generating_dependencies = false;
}
- if (!config.run_second_cpp()
- && (args_info.actual_language == "cu"
- || args_info.actual_language == "cuda")) {
- LOG("Source language is \"{}\"; not compiling preprocessed code",
- args_info.actual_language);
- config.set_run_second_cpp(true);
- }
-
args_info.direct_i_file = language_is_preprocessed(args_info.actual_language);
- if (args_info.output_is_precompiled_header && !config.run_second_cpp()) {
- // It doesn't work to create the .gch from preprocessed source.
- LOG_RAW("Creating precompiled header; not compiling preprocessed code");
- config.set_run_second_cpp(true);
- }
-
if (config.cpp_extension().empty()) {
std::string p_language = p_language_for_language(args_info.actual_language);
config.set_cpp_extension(extension_for_language(p_language).substr(1));
if (args_info.generating_dependencies) {
if (state.output_dep_origin == OutputDepOrigin::none) {
args_info.output_dep = util::with_extension(args_info.output_obj, ".d");
- if (!config.run_second_cpp()) {
- // If we're compiling preprocessed code we're sending dep_args to the
- // preprocessor so we need to use -MF to write to the correct .d file
- // location since the preprocessor doesn't know the final object path.
- state.dep_args.push_back("-MF");
- state.dep_args.push_back(args_info.output_dep);
- }
- }
-
- if (!args_info.dependency_target && !config.run_second_cpp()) {
- // If we're compiling preprocessed code we're sending dep_args to the
- // preprocessor so we need to use -MQ to get the correct target object
- // file in the .d file.
- state.dep_args.push_back("-MQ");
- state.dep_args.push_back(args_info.output_obj);
}
if (!args_info.dependency_target) {
Args compiler_args = state.common_args;
compiler_args.push_back(state.compiler_only_args_no_hash);
compiler_args.push_back(state.compiler_only_args);
-
- if (config.run_second_cpp()) {
- compiler_args.push_back(state.cpp_args);
- } else if (state.found_directives_only || state.found_rewrite_includes) {
- // Need to pass the macros and any other preprocessor directives again.
- compiler_args.push_back(state.cpp_args);
- if (state.found_directives_only) {
- state.cpp_args.push_back("-fdirectives-only");
- // The preprocessed source code still needs some more preprocessing.
- compiler_args.push_back("-fpreprocessed");
- compiler_args.push_back("-fdirectives-only");
- }
- if (state.found_rewrite_includes) {
- state.cpp_args.push_back("-frewrite-includes");
- // The preprocessed source code still needs some more preprocessing.
- compiler_args.push_back("-x");
- compiler_args.push_back(args_info.actual_language);
- }
- } else if (!state.explicit_language.empty()) {
- // Workaround for a bug in Apple's patched distcc -- it doesn't properly
- // reset the language specified with -x, so if -x is given, we have to
- // specify the preprocessed language explicitly.
- compiler_args.push_back("-x");
- compiler_args.push_back(p_language_for_language(state.explicit_language));
- }
+ compiler_args.push_back(state.cpp_args);
if (state.found_c_opt) {
compiler_args.push_back("-c");
Args preprocessor_args = state.common_args;
preprocessor_args.push_back(state.cpp_args);
-
- if (config.run_second_cpp()) {
- // When not compiling the preprocessed source code, only pass dependency
- // arguments to the compiler to avoid having to add -MQ, supporting e.g.
- // EDG-based compilers which don't support -MQ.
- compiler_args.push_back(state.dep_args);
- } else {
- // When compiling the preprocessed source code, pass dependency arguments to
- // the preprocessor since the compiler doesn't produce a .d file when
- // compiling preprocessed source code.
- preprocessor_args.push_back(state.dep_args);
- }
+ compiler_args.push_back(state.dep_args);
Args extra_args_to_hash = state.compiler_only_args;
- if (config.run_second_cpp()) {
- extra_args_to_hash.push_back(state.dep_args);
- }
+ extra_args_to_hash.push_back(state.dep_args);
if (state.hash_full_command_line) {
extra_args_to_hash.push_back(ctx.orig_args);
}
if (diagnostics_color_arg) {
compiler_args.push_back(*diagnostics_color_arg);
- if (!config.run_second_cpp()) {
- // If we're compiling preprocessed code we're keeping any warnings from
- // the preprocessor, so we need to make sure that they are in color.
- preprocessor_args.push_back(*diagnostics_color_arg);
- }
}
if (ctx.config.depend_mode() && !args_info.generating_includes
args.push_back("--");
}
- if (ctx.config.run_second_cpp()) {
- args.push_back(
- FMT("{}{}", ctx.args_info.input_file_prefix, ctx.args_info.input_file));
- } else {
- args.push_back(ctx.i_tmpfile);
- }
+ args.push_back(
+ FMT("{}{}", ctx.args_info.input_file_prefix, ctx.args_info.input_file));
if (ctx.args_info.seen_split_dwarf) {
// Remove any pre-existing .dwo file since we want to check if the compiler
ctx.i_tmpfile = preprocessed_path;
- if (!ctx.config.run_second_cpp()) {
- // If we are using the CPP trick, we need to remember this stderr data and
- // output it just before the main stderr from the compiler pass.
- ctx.cpp_stderr_data = std::move(cpp_stderr_data);
- hash.hash_delimiter("runsecondcpp");
- hash.hash("false");
- }
-
return hash.digest();
}
}
}
- if (!ctx.config.run_second_cpp() && ctx.config.is_compiler_group_msvc()) {
- LOG_RAW("Second preprocessor cannot be disabled");
- ctx.config.set_run_second_cpp(true);
- }
-
if (ctx.config.depend_mode()
- && !(ctx.config.run_second_cpp()
- && (ctx.args_info.generating_dependencies
- || ctx.args_info.generating_includes))) {
+ && !(ctx.args_info.generating_dependencies
+ || ctx.args_info.generating_includes)) {
LOG_RAW("Disabling depend mode");
ctx.config.set_depend_mode(false);
}
-// Copyright (C) 2010-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2025 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
// used.
int TAKES_PATH = 1 << 4;
-// The option only affects preprocessing; not passed to the compiler if
-// run_second_cpp is false.
+// The option only affects preprocessing; not included in the input hash in
+// preprocessor mode.
int AFFECTS_CPP = 1 << 5;
// The option only affects compilation; not passed to the preprocessor.
remote_storage,
reshare,
response_file_format,
- run_second_cpp,
sloppiness,
stats,
stats_log,
{"remote_storage", {ConfigItem::remote_storage} },
{"reshare", {ConfigItem::reshare} },
{"response_file_format", {ConfigItem::response_file_format} },
- {"run_second_cpp", {ConfigItem::run_second_cpp} },
{"secondary_storage", {ConfigItem::remote_storage, "remote_storage"}},
{"sloppiness", {ConfigItem::sloppiness} },
{"stats", {ConfigItem::stats} },
{"COMPILERTYPE", "compiler_type" },
{"COMPRESS", "compression" },
{"COMPRESSLEVEL", "compression_level" },
- {"CPP2", "run_second_cpp" },
{"DEBUG", "debug" },
{"DEBUGDIR", "debug_dir" },
{"DEBUGLEVEL", "debug_level" },
case ConfigItem::response_file_format:
return response_file_format_to_string(m_response_file_format);
- case ConfigItem::run_second_cpp:
- return format_bool(m_run_second_cpp);
-
case ConfigItem::sloppiness:
return format_sloppiness(m_sloppiness);
m_response_file_format = parse_response_file_format(value);
break;
- case ConfigItem::run_second_cpp:
- m_run_second_cpp = parse_bool(value, env_var_key, negate);
- break;
-
case ConfigItem::sloppiness:
m_sloppiness = parse_sloppiness(value);
break;
-// Copyright (C) 2019-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2025 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
bool remote_only() const;
const std::string& remote_storage() const;
bool reshare() const;
- bool run_second_cpp() const;
core::Sloppiness sloppiness() const;
bool stats() const;
const std::filesystem::path& stats_log() const;
void set_inode_cache(bool value);
void set_max_files(uint64_t value);
void set_msvc_dep_prefix(const std::string& value);
- void set_run_second_cpp(bool value);
void set_temporary_dir(const std::filesystem::path& value);
// Where to write configuration changes.
bool m_read_only_direct = false;
bool m_recache = false;
bool m_reshare = false;
- bool m_run_second_cpp = true;
bool m_remote_only = false;
std::string m_remote_storage;
core::Sloppiness m_sloppiness;
return m_reshare;
}
-inline bool
-Config::run_second_cpp() const
-{
- return m_run_second_cpp;
-}
-
inline bool
Config::remote_only() const
{
m_msvc_dep_prefix = value;
}
-inline void
-Config::set_run_second_cpp(bool value)
-{
- m_run_second_cpp = value;
-}
-
inline void
Config::set_temporary_dir(const std::filesystem::path& value)
{
addtest(clang_cu)
addtest(clang_cu_alias)
addtest(clang_cu_direct)
-addtest(clang_cu_nocpp2)
addtest(cleanup)
addtest(color_diagnostics)
addtest(config)
-addtest(cpp1)
addtest(debug_compilation_dir)
addtest(debug_prefix_map)
addtest(depend)
addtest(multi_arch)
addtest(namespace)
addtest(no_compression)
-addtest(nocpp2)
addtest(nvcc)
addtest(nvcc_direct)
addtest(nvcc_ldir)
-addtest(nvcc_nocpp2)
addtest(pch)
addtest(profiling)
addtest(profiling_clang)
addtest(stats_log)
addtest(trim_dir)
addtest(upgrade)
-
expect_equal_text_content stderr_2_ref.txt stderr_2.txt
# -------------------------------------------------------------------------
- TEST "Merging stderr"
+ TEST "Stderr from cpp not emitted"
cat >compiler.sh <<EOF
#!/bin/sh
EOF
chmod +x compiler.sh
- unset CCACHE_NOCPP2
stderr=$($CCACHE ./compiler.sh -c test1.c 2>stderr)
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_content stderr "[cc_stderr]"
- stderr=$(CCACHE_NOCPP2=1 $CCACHE ./compiler.sh -c test1.c 2>stderr)
- expect_stat preprocessed_cache_hit 0
- expect_stat cache_miss 2
- expect_stat files_in_cache 2
- expect_content stderr "[cpp_stderr][cc_stderr]"
-
# -------------------------------------------------------------------------
TEST "Stderr and dependency file"
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
- if [ -z "$CCACHE_NOCPP2" ]; then
- expect_content_pattern compiler.args "(-E -o * test1.c)(-c -o test1.o test1.c)"
- fi
+ expect_content_pattern compiler.args "(-E -o * test1.c)(-c -o test1.o test1.c)"
rm compiler.args
$CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
expect_stat files_in_cache 2
- if [ -z "$CCACHE_NOCPP2" ]; then
- expect_content_pattern compiler.args "(-E -o * test1.c)(-Werror -rdynamic -c -o test1.o test1.c)"
- fi
+ expect_content_pattern compiler.args "(-E -o * test1.c)(-Werror -rdynamic -c -o test1.o test1.c)"
rm compiler.args
# -------------------------------------------------------------------------
+++ /dev/null
-SUITE_clang_cu_nocpp2_PROBE() {
- clang_cu_PROBE
-}
-
-SUITE_clang_cu_nocpp2_SETUP() {
- export CCACHE_NOCPP2=1
-
- clang_cu_SETUP
-}
-
-SUITE_clang_cu_nocpp2() {
- clang_cu_tests
-}
}
SUITE_color_diagnostics_SETUP() {
- if $run_second_cpp; then
- export CCACHE_CPP2=1
- else
- export CCACHE_NOCPP2=1
- fi
-
unset GCC_COLORS
export TERM=vt100
}
done
}
-color_diagnostics_test() {
+SUITE_color_diagnostics() {
# -------------------------------------------------------------------------
- TEST "Colored diagnostics automatically disabled when stderr is not a TTY (run_second_cpp=$run_second_cpp)"
+ TEST "Colored diagnostics automatically disabled when stderr is not a TTY"
color_diagnostics_generate_code test1.c
$CCACHE_COMPILE -Wreturn-type -c -o test1.o test1.c 2>test1.stderr
expect_stat preprocessed_cache_hit 1
# -------------------------------------------------------------------------
- TEST "Colored diagnostics automatically enabled when stderr is a TTY (run_second_cpp=$run_second_cpp)"
+ TEST "Colored diagnostics automatically enabled when stderr is a TTY"
color_diagnostics_generate_code test1.c
color_diagnostics_run_on_pty test1.output "$CCACHE_COMPILE -Wreturn-type -c -o test1.o test1.c"
while read -r case; do
# ---------------------------------------------------------------------
- TEST "Cache object shared across ${case} (run_second_cpp=$run_second_cpp)"
+ TEST "Cache object shared across ${case}"
color_diagnostics_generate_code test1.c
local each
color_diagnostics_generate_permutations "${#A[@]}"
)
}
-
-SUITE_color_diagnostics() {
- run_second_cpp=true color_diagnostics_test
- run_second_cpp=false color_diagnostics_test
-}
+++ /dev/null
-SUITE_cpp1_PROBE() {
- touch test.c
- if $COMPILER_TYPE_GCC; then
- if ! $COMPILER -E -fdirectives-only test.c >&/dev/null; then
- echo "-fdirectives-only not supported by compiler"
- return
- fi
- elif $COMPILER_TYPE_CLANG; then
- if ! $COMPILER -E -frewrite-includes test.c >&/dev/null; then
- echo "-frewrite-includes not supported by compiler"
- return
- fi
- if $HOST_OS_WINDOWS && ! $COMPILER_USES_MSVC; then
- echo "This test is broken on msys2 clang: Stores wrong file names like 'tmp.cpp_stdout.2Gq' instead of 'test1.c'."
- return
- fi
- else
- echo "Unknown compiler: $COMPILER"
- return
- fi
-}
-
-SUITE_cpp1_SETUP() {
- export CCACHE_NOCPP2=1
- echo "#define FOO 1" >test1.h
- backdate test1.h
- echo '#include "test1.h"' >test1.c
- echo '#define BAR 2' >>test1.c
- echo 'int foo(int x) { return FOO; }' >>test1.c
- echo 'int bar(int x) { return BAR; }' >>test1.c
- echo 'int baz(int x) { return BAZ; }' >>test1.c
-}
-
-SUITE_cpp1() {
- if $COMPILER_TYPE_GCC; then
- cpp_flag="-fdirectives-only"
- elif $COMPILER_TYPE_CLANG; then
- cpp_flag="-frewrite-includes"
- fi
- cpp_flag="$cpp_flag -DBAZ=3"
-
- # -------------------------------------------------------------------------
- TEST "Base case"
-
- $COMPILER $cpp_flag -c -o reference_test1.o test1.c
-
- $CCACHE_COMPILE $cpp_flag -c test1.c
- expect_stat direct_cache_hit 0
- expect_stat preprocessed_cache_hit 0
- expect_stat cache_miss 1
- expect_stat files_in_cache 1
- expect_equal_object_files reference_test1.o test1.o
-
- unset CCACHE_NODIRECT
-
- $CCACHE_COMPILE $cpp_flag -c test1.c
- expect_stat direct_cache_hit 0
- expect_stat preprocessed_cache_hit 1
- expect_stat cache_miss 1
- expect_stat files_in_cache 2
- expect_equal_object_files reference_test1.o test1.o
-
- $CCACHE_COMPILE $cpp_flag -c test1.c
- expect_stat direct_cache_hit 1
- expect_stat preprocessed_cache_hit 1
- expect_stat cache_miss 1
- expect_stat files_in_cache 2
- expect_equal_object_files reference_test1.o test1.o
-}
$CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
-
- CCACHE_NOCPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
- expect_stat preprocessed_cache_hit 1
- expect_stat cache_miss 2
-
- CCACHE_NOCPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
- expect_stat preprocessed_cache_hit 2
- expect_stat cache_miss 2
}
+++ /dev/null
-SUITE_nocpp2_PROBE() {
- if $HOST_OS_WINDOWS; then
- echo "CCACHE_NOCPP2 does not work correct on Windows"
- return
- fi
-}
-
-SUITE_nocpp2_SETUP() {
- export CCACHE_NOCPP2=1
- generate_code 1 test1.c
-}
-
-SUITE_nocpp2() {
- base_tests
-}
+++ /dev/null
-SUITE_nvcc_nocpp2_PROBE() {
- nvcc_PROBE
-}
-
-SUITE_nvcc_nocpp2_SETUP() {
- export CCACHE_NOCPP2=1
- nvcc_SETUP
-}
-
-SUITE_nvcc_nocpp2() {
- nvcc_tests
-}
-// Copyright (C) 2010-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2025 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
CHECK(process_args(ctx).error() == Statistic::unsupported_compiler_option);
}
-TEST_CASE("dependency_args_to_preprocessor_if_run_second_cpp_is_false")
-{
- TestContext test_context;
- const std::string dep_args =
- "-MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2 -Wp,-MP"
- " -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf";
- Context ctx;
- ctx.orig_args = Args::from_string("cc " + dep_args + " -c foo.c -o foo.o");
- util::write_file("foo.c", "");
- ctx.config.set_run_second_cpp(false);
-
- const auto result = process_args(ctx);
-
- CHECK(result);
- CHECK(result->preprocessor_args.to_string() == "cc " + dep_args);
- CHECK(result->extra_args_to_hash.to_string() == "");
- CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE("dependency_args_to_compiler_if_run_second_cpp_is_true")
+TEST_CASE("dependency_args_to_compiler")
{
TestContext test_context;
const std::string dep_args =
CHECK(result->compiler_args.to_string() == "cc -c " + dep_args);
}
-TEST_CASE("cpp_only_args_to_preprocessor_if_run_second_cpp_is_false")
-{
- TestContext test_context;
- const std::string cpp_args =
- "-I. -idirafter . -iframework. -imacros . -imultilib . -include test.h"
- " -include-pch test.pch -iprefix . -iquote . -isysroot . -isystem ."
- " -iwithprefix . -iwithprefixbefore . -DTEST_MACRO -DTEST_MACRO2=1 -F."
- " -trigraphs -fworking-directory -fno-working-directory";
- const std::string dep_args =
- "-MD -MMD -MP -MF foo.d -MT mt1 -MT mt2 -MQ mq1 -MQ mq2 -Wp,-MP"
- " -Wp,-MT,wpmt -Wp,-MQ,wpmq -Wp,-MF,wpf";
- Context ctx;
- ctx.orig_args =
- Args::from_string("cc " + cpp_args + " " + dep_args + " -c foo.c -o foo.o");
- util::write_file("foo.c", "");
- ctx.config.set_run_second_cpp(false);
-
- const auto result = process_args(ctx);
-
- CHECK(result);
- CHECK(result->preprocessor_args.to_string()
- == "cc " + cpp_args + " " + dep_args);
- CHECK(result->extra_args_to_hash.to_string() == "");
- CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE(
- "cpp_only_args_to_preprocessor_and_compiler_if_run_second_cpp_is_true")
+TEST_CASE("cpp_only_args_to_preprocessor_and_compiler")
{
TestContext test_context;
const std::string cpp_args =
CHECK(result->compiler_args.to_string() == "cc -c " + dep_args);
}
-TEST_CASE("MQ_flag_should_not_be_added_if_run_second_cpp_is_true")
-{
- TestContext test_context;
- Context ctx;
- ctx.orig_args = Args::from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
- util::write_file("foo.c", "");
-
- const auto result = process_args(ctx);
-
- CHECK(result);
- CHECK(result->preprocessor_args.to_string() == "cc");
- CHECK(result->extra_args_to_hash.to_string() == "-MD -MF foo.d");
- CHECK(result->compiler_args.to_string() == "cc -c -MD -MF foo.d");
-}
-
-TEST_CASE("MQ_flag_should_be_added_if_run_second_cpp_is_false")
-{
- TestContext test_context;
- Context ctx;
- ctx.orig_args = Args::from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
- util::write_file("foo.c", "");
- ctx.config.set_run_second_cpp(false);
-
- const auto result = process_args(ctx);
-
- CHECK(result);
- CHECK(result->preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
- CHECK(result->extra_args_to_hash.to_string() == "");
- CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE("MF_should_be_added_if_run_second_cpp_is_false")
-{
- TestContext test_context;
- Context ctx;
- ctx.orig_args = Args::from_string("cc -c -MD foo.c -o foo.o");
- util::write_file("foo.c", "");
- ctx.config.set_run_second_cpp(false);
-
- const auto result = process_args(ctx);
-
- CHECK(result);
- CHECK(result->preprocessor_args.to_string() == "cc -MD -MF foo.d -MQ foo.o");
- CHECK(result->extra_args_to_hash.to_string() == "");
- CHECK(result->compiler_args.to_string() == "cc -c");
-}
-
-TEST_CASE("MF_should_not_be_added_if_run_second_cpp_is_true")
-{
- TestContext test_context;
- Context ctx;
- ctx.orig_args = Args::from_string("cc -c -MD foo.c -o foo.o");
- util::write_file("foo.c", "");
-
- const auto result = process_args(ctx);
-
- CHECK(result);
- CHECK(result->preprocessor_args.to_string() == "cc");
- CHECK(result->extra_args_to_hash.to_string() == "-MD");
- CHECK(result->compiler_args.to_string() == "cc -c -MD");
-}
-
TEST_CASE("equal_sign_after_MF_should_be_removed")
{
TestContext test_context;
-// Copyright (C) 2011-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2011-2025 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
CHECK_FALSE(config.remote_only());
CHECK(config.remote_storage().empty());
CHECK_FALSE(config.reshare());
- CHECK(config.run_second_cpp());
CHECK(config.sloppiness().to_bitmask() == 0);
CHECK(config.stats());
CHECK(config.temporary_dir().empty()); // Set later
"read_only_direct = true\n"
"recache = true\n"
"reshare = true\n"
- "run_second_cpp = false\n"
"sloppiness = time_macros ,include_file_mtime"
" include_file_ctime,file_stat_matches,file_stat_matches_ctime,pch_defines"
" , no_system_headers,system_headers,clang_index_store,ivfsoverlay,"
CHECK(config.read_only_direct());
CHECK(config.recache());
CHECK(config.reshare());
- CHECK_FALSE(config.run_second_cpp());
CHECK(config.sloppiness().to_bitmask()
== (static_cast<uint32_t>(core::Sloppy::clang_index_store)
| static_cast<uint32_t>(core::Sloppy::file_stat_matches)
"remote_storage = rs\n"
"reshare = true\n"
"response_file_format = posix\n"
- "run_second_cpp = false\n"
"sloppiness = include_file_mtime, include_file_ctime, time_macros,"
" file_stat_matches, file_stat_matches_ctime, pch_defines, system_headers,"
" clang_index_store, ivfsoverlay, gcno_cwd \n"
"(test.conf) remote_storage = rs",
"(test.conf) reshare = true",
"(test.conf) response_file_format = posix",
- "(test.conf) run_second_cpp = false",
"(test.conf) sloppiness = clang_index_store, file_stat_matches,"
" file_stat_matches_ctime, gcno_cwd, include_file_ctime,"
" include_file_mtime, ivfsoverlay, pch_defines, system_headers,"