Browse Source

We want -MQ instead of -MT for mkfile deps

default_compile_flags
vector-of-bool 4 years ago
parent
commit
9a02f2436c
4 changed files with 26 additions and 13 deletions
  1. +7
    -0
      src/dds/build/file_deps.test.cpp
  2. +7
    -1
      src/dds/build/plan/compile_exec.cpp
  3. +11
    -11
      src/dds/toolchain/from_json.test.cpp
  4. +1
    -1
      src/dds/toolchain/toolchain.cpp

+ 7
- 0
src/dds/build/file_deps.test.cpp View File

deps = dds::parse_mkfile_deps_str("foo.o: bar.c \\\n baz.c"); deps = dds::parse_mkfile_deps_str("foo.o: bar.c \\\n baz.c");
CHECK(deps.output == "foo.o"); CHECK(deps.output == "foo.o");
CHECK(deps.inputs == path_vec("bar.c", "baz.c")); CHECK(deps.inputs == path_vec("bar.c", "baz.c"));

deps = dds::parse_mkfile_deps_str(
"/some-path/Ю́рий\\ Алексе́евич\\ Гага́рин/build/obj/foo.main.cpp.o: \\\n"
" /foo.main.cpp \\\n"
" /stdc-predef.h\n");
CHECK(deps.output == "/some-path/Ю́рий Алексе́евич Гага́рин/build/obj/foo.main.cpp.o");
CHECK(deps.inputs == path_vec("/foo.main.cpp", "/stdc-predef.h"));
} }


TEST_CASE("Invalid deps") { TEST_CASE("Invalid deps") {

+ 7
- 1
src/dds/build/plan/compile_exec.cpp View File

#include <dds/util/string.hpp> #include <dds/util/string.hpp>
#include <dds/util/time.hpp> #include <dds/util/time.hpp>


#include <neo/assert.hpp>
#include <range/v3/range/conversion.hpp> #include <range/v3/range/conversion.hpp>
#include <range/v3/view/filter.hpp> #include <range/v3/view/filter.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>
} else { } else {
dds_log(trace, "Loading compilation dependencies from {}", df_path.string()); dds_log(trace, "Loading compilation dependencies from {}", df_path.string());
auto dep_info = dds::parse_mkfile_deps_file(df_path); auto dep_info = dds::parse_mkfile_deps_file(df_path);
assert(dep_info.output == cf.object_file_path);
neo_assert(invariant,
dep_info.output == cf.object_file_path,
"Generated mkfile deps output path does not match the object file path that "
"we gave it to compile into.",
dep_info.output.string(),
cf.object_file_path.string());
dep_info.command = quote_command(cf.cmd_info.command); dep_info.command = quote_command(cf.cmd_info.command);
dep_info.command_output = compiler_output; dep_info.command_output = compiler_output;
ret_deps_info = std::move(dep_info); ret_deps_info = std::move(dep_info);

+ 11
- 11
src/dds/toolchain/from_json.test.cpp View File



TEST_CASE("Generating toolchain commands") { TEST_CASE("Generating toolchain commands") {
check_tc_compile("{compiler_id: 'gnu'}", check_tc_compile("{compiler_id: 'gnu'}",
"g++ -fPIC -pthread -MD -MF foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"g++ -fPIC -pthread -MD -MF foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"g++ -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion " "g++ -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion "
"-MD -MF foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"-MD -MF foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"ar rcs stuff.a foo.o bar.o", "ar rcs stuff.a foo.o bar.o",
"g++ -fPIC foo.o bar.a -pthread -omeow.exe"); "g++ -fPIC foo.o bar.a -pthread -omeow.exe");


check_tc_compile("{compiler_id: 'gnu', debug: true}", check_tc_compile("{compiler_id: 'gnu', debug: true}",
"g++ -g -fPIC -pthread -MD -MF foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"g++ -g -fPIC -pthread -MD -MF foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"g++ -g -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion " "g++ -g -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion "
"-MD -MF foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"-MD -MF foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"ar rcs stuff.a foo.o bar.o", "ar rcs stuff.a foo.o bar.o",
"g++ -fPIC foo.o bar.a -pthread -omeow.exe -g"); "g++ -fPIC foo.o bar.a -pthread -omeow.exe -g");


check_tc_compile("{compiler_id: 'gnu', debug: true, optimize: true}", check_tc_compile("{compiler_id: 'gnu', debug: true, optimize: true}",
"g++ -O2 -g -fPIC -pthread -MD -MF foo.o.d -MT foo.o -c foo.cpp "
"g++ -O2 -g -fPIC -pthread -MD -MF foo.o.d -MQ foo.o -c foo.cpp "
"-ofoo.o", "-ofoo.o",
"g++ -O2 -g -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion " "g++ -O2 -g -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion "
"-MD -MF foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"-MD -MF foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"ar rcs stuff.a foo.o bar.o", "ar rcs stuff.a foo.o bar.o",
"g++ -fPIC foo.o bar.a -pthread -omeow.exe -O2 -g"); "g++ -fPIC foo.o bar.a -pthread -omeow.exe -O2 -g");


check_tc_compile( check_tc_compile(
"{compiler_id: 'gnu', debug: 'split', optimize: true}", "{compiler_id: 'gnu', debug: 'split', optimize: true}",
"g++ -O2 -g -gsplit-dwarf -fPIC -pthread -MD -MF foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"g++ -O2 -g -gsplit-dwarf -fPIC -pthread -MD -MF foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"g++ -O2 -g -gsplit-dwarf -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion -MD -MF " "g++ -O2 -g -gsplit-dwarf -fPIC -pthread -Wall -Wextra -Wpedantic -Wconversion -MD -MF "
"foo.o.d -MT foo.o -c foo.cpp -ofoo.o",
"foo.o.d -MQ foo.o -c foo.cpp -ofoo.o",
"ar rcs stuff.a foo.o bar.o", "ar rcs stuff.a foo.o bar.o",
"g++ -fPIC foo.o bar.a -pthread -omeow.exe -O2 -g -gsplit-dwarf"); "g++ -fPIC foo.o bar.a -pthread -omeow.exe -O2 -g -gsplit-dwarf");


"-MD", "-MD",
"-MF", "-MF",
"foo.o.d", "foo.o.d",
"-MT",
"-MQ",
"foo.o", "foo.o",
"-c", "-c",
"foo.cpp", "foo.cpp",
"-MD", "-MD",
"-MF", "-MF",
"foo.o.d", "foo.o.d",
"-MT",
"-MQ",
"foo.o", "foo.o",
"-c", "-c",
"foo.cpp", "foo.cpp",
"-MD", "-MD",
"-MF", "-MF",
"foo.o.d", "foo.o.d",
"-MT",
"-MQ",
"foo.o", "foo.o",
"-c", "-c",
"foo.cpp", "foo.cpp",

+ 1
- 1
src/dds/toolchain/toolchain.cpp View File

{"-MD"sv, {"-MD"sv,
"-MF"sv, "-MF"sv,
std::string_view(gnu_depfile_path->string()), std::string_view(gnu_depfile_path->string()),
"-MT"sv,
"-MQ"sv,
std::string_view(spec.out_path.string())}); std::string_view(spec.out_path.string())});
} else if (_deps_mode == file_deps_mode::msvc) { } else if (_deps_mode == file_deps_mode::msvc) {
flags.push_back("/showIncludes"); flags.push_back("/showIncludes");

Loading…
Cancel
Save