Closed Bug 1390524 Opened 4 years ago Closed 4 years ago

extra_toolchain_flags applies to host and target compiles, when it should only apply to target


(Firefox Build System :: General, enhancement)

Not set


(firefox57 fixed)

Tracking Status
firefox57 --- fixed


(Reporter: froydnj, Assigned: froydnj)




(2 files)

I discovered this today when I attempted to modify extra_toolchain_flags on Android to pass the correct flags for clang:

@depends(android_platform, android_toolchain)
def extra_toolchain_flags(platform_dir, toolchain_dir):
    if not platform_dir:
        return []
    # -idirafter does not work correctly with llvm; the default #include search
    # paths include host paths outside of the NDK (!), so using -idirafter
    # inserts the android platform's /usr/include after the host's /usr/include,
    # which obviously doesn't work that well.  Using -isystem puts things in
    # the correct place.
    return ['-isystem',
            os.path.join(platform_dir, 'usr', 'include'),

and then running configure says:

checking the host C compiler works... no
DEBUG: Creating `/tmp/conftest.qZJV7T.c` with content:
DEBUG: | int
DEBUG: | main(void)
DEBUG: | {
DEBUG: |   ;
DEBUG: |   return 0;
DEBUG: | }
DEBUG: Executing: `/usr/bin/gcc -std=gnu99 -isystem /home/froydnj/.mozbuild/android-ndk-r11b/platforms/android-9/arch-arm/usr/include -gcc-toolchain /home/froydnj/.mozbuild/android-ndk-r11b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -c /tmp/conftest.qZJV7T.c`

Notice that we're passing the aforementioned flags to the host compiler.  I think we get away with this in our current Android builds because we're passing -idirafter, which the host GCC understands, and which is harmless.  But -gcc-toolchain is obviously clang-specific, and attempting to pass it along to the host results in badness.
Inspecting logs suggests that this passing of flags only happens during
moz.configure, so it's not as bad as it could be, but it's still something we
should fix.
Attachment #8897530 - Flags: review?(mh+mozilla)
Attachment #8897530 - Flags: review?(mh+mozilla) → review+
Assignee: nobody → nfroyd
Pushed by
correctly pass extra_toolchain_flags only to the target; r=glandium
Backed out for build bustage in compiler_class() takes exactly 2 arguments (1 given):

Failure log:

> TEST-UNEXPECTED-FAIL | /home/worker/workspace/build/src/python/mozbuild/mozbuild/test/configure/ | TestHeaderChecks.test_check_header, line 176: compiler_class() takes exactly 2 arguments (1 given)
Flags: needinfo?(nfroyd)
Attached patch fix test bustageSplinter Review
Like an idiot, I forgot to run the configure tests, and of course there was
bustage.  We were abusing compiler_class as a decorator, which causes
problems.  This is the easiest way I can think of to fix it, but the fix was
complicated enough that I thought it was worth somebody taking a second look.
Attachment #8898437 - Flags: review?(mh+mozilla)
Flags: needinfo?(nfroyd)
Comment on attachment 8898437 [details] [diff] [review]
fix test bustage

Review of attachment 8898437 [details] [diff] [review]:

::: python/mozbuild/mozbuild/test/configure/
@@ +60,5 @@
> +                if isfunction(obj):
> +                    return depends(when=True)(obj)
> +                return depends(when=True)(lambda: obj)
> +
> +            target = dependable(True)

that's a lot of code for something that could be written as:
  def target():
      return True
Attachment #8898437 - Flags: review?(mh+mozilla) → review+
or even `target = depends(when=True)(lambda: True)`
Pushed by
correctly pass extra_toolchain_flags only to target compiles; r=glandium
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.