Closed Bug 1739644 Opened 9 months ago Closed 9 months ago

./mach clang-format fails when mozconfig is set up for cross compile

Categories

(Firefox Build System :: Source Code Analysis, defect)

defect

Tracking

(firefox96 fixed)

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: bhearsum, Assigned: andi)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Attached file mozconfig

I cross compile (host: Linux, target: Windows) often. When my mozconfig is set up for this (attached), clang-format downloads a Linux toolchain, but then tries to run a Windows clang-format.exe that doesn't exist. Ideally, it would run the Linux clang-format it downloaded, although downloading and running the Windows one would arguably be acceptable (at least it would work).

I noticed this happened for the mingw cross compile also which I do locally every once in a while.

Try this:

--- a/python/mozbuild/mozbuild/code_analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code_analysis/mach_commands.py
@@ -1247,19 +1247,19 @@ def autotest(
             clang_tools_path,
             "clang-tidy",
             "bin",
-            "clang-tidy" + config.substs.get("BIN_SUFFIX", ""),
+            "clang-tidy" + config.substs.get("HOST_BIN_SUFFIX", ""),
         )
         clang_paths._clang_format_path = mozpath.join(
             clang_tools_path,
             "clang-tidy",
             "bin",
-            "clang-format" + config.substs.get("BIN_SUFFIX", ""),
+            "clang-format" + config.substs.get("HOST_BIN_SUFFIX", ""),
         )
         clang_paths._clang_apply_replacements = mozpath.join(
             clang_tools_path,
             "clang-tidy",
             "bin",
-            "clang-apply-replacements" + config.substs.get("BIN_SUFFIX", ""),
+            "clang-apply-replacements" + config.substs.get("HOST_BIN_SUFFIX", ""),
         )
         clang_paths._run_clang_tidy_path = mozpath.join(
             clang_tools_path, "clang-tidy", "bin", "run-clang-tidy"
@@ -2210,19 +2210,19 @@ def _set_clang_tools_paths(command_context):
         clang_paths._clang_tools_path,
         "clang-tidy",
         "bin",
-        "clang-tidy" + config.substs.get("BIN_SUFFIX", ""),
+        "clang-tidy" + config.substs.get("HOST_BIN_SUFFIX", ""),
     )
     clang_paths._clang_format_path = mozpath.join(
         clang_paths._clang_tools_path,
         "clang-tidy",
         "bin",
-        "clang-format" + config.substs.get("BIN_SUFFIX", ""),
+        "clang-format" + config.substs.get("HOST_BIN_SUFFIX", ""),
     )
     clang_paths._clang_apply_replacements = mozpath.join(
         clang_paths._clang_tools_path,
         "clang-tidy",
         "bin",
-        "clang-apply-replacements" + config.substs.get("BIN_SUFFIX", ""),
+        "clang-apply-replacements" + config.substs.get("HOST_BIN_SUFFIX", ""),
     )
     clang_paths._run_clang_tidy_path = mozpath.join(
         clang_paths._clang_tools_path,

Works for me. Thanks!

Original patch by glandium.

Assignee: nobody → bpostelnicu
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e011ef7d5445
make clang based tooling work for cross compile builds also. r=firefox-static-analysis-reviewers,sylvestre DONTBUILD
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
You need to log in before you can comment on or make changes to this bug.