Closes #1090.
// Split dwarf information (GCC 4.8 and up). Contains pathname if not empty.
std::string output_dwo;
+ // Assembler listing file.
+ std::string output_al;
+
// The .gch/.pch/.pth file used for compilation.
std::string included_pch_file;
case FileType::stdout_output:
return "<stdout>";
+
+ case FileType::assembler_listing:
+ return ".al";
}
return k_unknown_file_type;
// Text sent to standard output.
stdout_output = 8,
+
+ // Assembler listing file from -Wa,-a=file.
+ assembler_listing = 9,
};
const char* file_type_to_string(FileType type);
dest_path = Result::gcno_file_in_mangled_form(m_ctx);
}
break;
+
+ case FileType::assembler_listing:
+ dest_path = m_ctx.args_info.output_al;
+ break;
}
if (file_type == FileType::stdout_output
bool found_mf_opt = false;
bool found_wp_md_or_mmd_opt = false;
bool found_md_or_mmd_opt = false;
+ bool found_opt_Wa_a = false;
std::string explicit_language; // As specified with -x.
std::string input_charset_option; // -finput-charset=...
++i;
}
- if (util::starts_with(args[i], "-Wa,")
- && args[i].find('=') != std::string::npos) {
- LOG("Assembler listing file (-Wa,...=file) is currently not supported: {}",
- args[i]);
- return Statistic::unsupported_compiler_option;
+ if (util::starts_with(args[i], "-Wa,")) {
+ for (const auto part : util::Tokenizer(&args[i][4], ",")) {
+ if (util::starts_with(part, "-a")) {
+ if (state.found_opt_Wa_a) {
+ LOG_RAW(
+ "Multiple assembler listing options (-Wa,-a) are not supported");
+ return Statistic::unsupported_compiler_option;
+ }
+ state.found_opt_Wa_a = true;
+
+ const auto eq_pos = part.find('=');
+ if (eq_pos != std::string_view::npos) {
+ args_info.output_al = part.substr(eq_pos + 1);
+ }
+ }
+ }
}
// Handle options that should not be passed to the preprocessor.
result_writer.write_file(Result::FileType::dwarf_object,
ctx.args_info.output_dwo);
}
+ if (!ctx.args_info.output_al.empty()) {
+ result_writer.write_file(Result::FileType::assembler_listing,
+ ctx.args_info.output_al);
+ }
const auto file_size_and_count_diff = result_writer.finalize();
if (file_size_and_count_diff) {
continue;
}
+ if (util::starts_with(args[i], "-Wa,")) {
+ // We have to distinguish between three cases:
+ //
+ // Case 1: -Wa,-a (write to stdout)
+ // Case 2: -Wa,-a= (write to stdout and stderr)
+ // Case 3: -Wa,-a=file (write to file)
+ //
+ // No need to include the file part in case 3 since the filename is not
+ // part of the output.
+
+ using util::Tokenizer;
+ hash.hash_delimiter("arg");
+ bool first = true;
+ for (const auto part :
+ Tokenizer(args[i], ",", Tokenizer::Mode::include_empty)) {
+ if (first) {
+ first = false;
+ } else {
+ hash.hash(",");
+ }
+ if (util::starts_with(part, "-a")) {
+ const auto eq_pos = part.find('=');
+ if (eq_pos < part.size() - 1) {
+ // Case 3:
+ hash.hash(part.substr(0, eq_pos + 1));
+ hash.hash("file");
+ continue;
+ }
+ }
+ // Case 1 and 2:
+ hash.hash(part);
+ }
+ continue;
+ }
+
// The -fdebug-prefix-map option may be used in combination with
// CCACHE_BASEDIR to reuse results across different directories. Skip using
// the value of the option from hashing but still hash the existence of the
fi
# -------------------------------------------------------------------------
- if $COMPILER -c -Wa,-a=test1.lst test1.c >&/dev/null; then
+ if $COMPILER -c -Wa,-a=test1.lst,-L test1.c >&/dev/null && [ -e test1.lst ]; then
TEST "-Wa,-a=file"
- $CCACHE_COMPILE -c -Wa,-a=test1.lst test1.c
+ # Check that -Wa options after -a are handled.
+
+ $CCACHE_COMPILE -c -Wa,-a=test1.lst,-L test1.c
expect_stat preprocessed_cache_hit 0
- expect_stat cache_miss 0
+ expect_stat cache_miss 1
+ rm test1.lst
+
+ $CCACHE_COMPILE -c -Wa,-a=test1.lst,-L test1.c
+ expect_stat preprocessed_cache_hit 1
+ expect_stat cache_miss 1
+ rm test1.lst
+
+ # Check that the filename can be changed without changing the hash.
+
+ $CCACHE_COMPILE -c -Wa,-a=test2.lst,-L test1.c
+ expect_stat preprocessed_cache_hit 2
+ expect_stat cache_miss 1
+ rm test2.lst
+
+ # Check that -Wa options before -a are handled.
+
+ $CCACHE_COMPILE -c -Wa,-L,-a=test1.lst test1.c
+ expect_stat preprocessed_cache_hit 2
+ expect_stat cache_miss 2
+ rm test1.lst
+
+ $CCACHE_COMPILE -c -Wa,-L,-a=test1.lst test1.c
+ expect_stat preprocessed_cache_hit 3
+ expect_stat cache_miss 2
+ rm test1.lst
+
+ # Check that -Wa,-aOPTIONS=file is different than -Wa,-a=file.
+
+ $CCACHE_COMPILE -c -Wa,-as=test1.lst test1.c
+ expect_stat preprocessed_cache_hit 3
+ expect_stat cache_miss 3
+ rm test1.lst
+
+ $CCACHE_COMPILE -c -Wa,-as=test1.lst test1.c
+ expect_stat preprocessed_cache_hit 4
+ expect_stat cache_miss 3
+ rm test1.lst
+
+ # Multiple -Wa,-a options are not supported.
+
+ $CCACHE_COMPILE -c -Wa,-a=test1.lst -Wa,-as=test1.lst test1.c
+ expect_stat preprocessed_cache_hit 4
+ expect_stat cache_miss 3
expect_stat unsupported_compiler_option 1
+ rm test1.lst
fi
# -------------------------------------------------------------------------