New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 598599 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit 26 days ago
Closed: Apr 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug

Blocking:
issue 354261



Sign in to add a comment

GN: How to pass link options in astep on Windows?

Project Member Reported by shinyak@chromium.org, Mar 29 2016

Issue description

When /GL option is passed to cl.exe, /LTCG option should be passed to lib.exe and link.exe.

Since ldflags has /LTCG option, I added {{ldflags}} in rspfile_content (see [2]), but nothing happened.
Looking build.ninja generated by gyp, libflags options is passed to lib.exe, but the one which gn generated does not have
that flag. gn does not know such a flag, right?

What is the recommended way to pass library flags to lib.exe?
gn should know that?

[1] (current tool("alink") in toolchain/win/BUILD.gn)

    tool("alink") {
      rspfile = "{{output}}.rsp"
      command = "$python_path gyp-win-tool link-wrapper $env False lib.exe /nologo /ignore:4221 /OUT:{{output}} @$rspfile"
      description = "LIB {{output}}"
      outputs = [
        # Ignore {{output_extension}} and always use .lib, there's no reason to
        # allow targets to override this extension on Windows.
        "{{target_out_dir}}/{{target_output_name}}.lib",
      ]
      default_output_extension = ".lib"

      # The use of inputs_newline is to work around a fixed per-line buffer
      # size in the linker.
      rspfile_content = "{{inputs_newline}}"
    }

[2]
rspfile_content = "{{inputs_newline}} {{ldflags}}"
 
Looking ldflags help, 

"so applying ldflags to source sets or static libraries will be a no-op. If you want to apply ldflags to dependent targets, put them in a config and set it in the all_dependent_configs or public_configs."

Hmm, then, we need to add some dependency in all static link target, right??
Blocking: 354261
Cc: sebmarchand@chromium.org brettw@chromium.org brucedaw...@chromium.org
Labels: -Pri-3 Proj-GN-Migration Pri-2
Hi Shinyak@,

You're right, it looks like we might not have a way to set flags specifically for the lib/alink step, and need to add one.

Brett/Bruce/Sébastien, thoughts?
Having a way to specify which flags should be passed to lib.exe sounds like a good idea, for full flexibility.

Owner: brettw@chromium.org
Status: Assigned (was: Untriaged)
Brett, can you take a look at this?

Comment 5 by brettw@chromium.org, Apr 18 2016

Looks like we will need to add arflags like GYP has. We can't use ldflags easily because those are set all over the place assuming it's only going to ld.
Project Member

Comment 6 by bugdroid1@chromium.org, Apr 19 2016

Status: Started (was: Assigned)
Components: Build

Comment 9 by brettw@chromium.org, Apr 20 2016

Status: Fixed (was: Started)
Project Member

Comment 10 by bugdroid1@chromium.org, Apr 20 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c33bfab4e4dc2702bc6ccc36038defd850837bd2

commit c33bfab4e4dc2702bc6ccc36038defd850837bd2
Author: brettw <brettw@chromium.org>
Date: Wed Apr 20 19:38:45 2016

Implement arflags in the GN build.

This flag was recently added in GN. This patch hooks it up to the toolchains
and moves some flags to use it that previously had to be hardcoded on the
tool command itself.

Remove concurrent_links variable from gcc_toolchain which was unused.

BUG= 598599 

Review URL: https://codereview.chromium.org/1896163003

Cr-Commit-Position: refs/heads/master@{#388554}

[modify] https://crrev.com/c33bfab4e4dc2702bc6ccc36038defd850837bd2/build/config/compiler/BUILD.gn
[modify] https://crrev.com/c33bfab4e4dc2702bc6ccc36038defd850837bd2/build/config/win/BUILD.gn
[modify] https://crrev.com/c33bfab4e4dc2702bc6ccc36038defd850837bd2/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/c33bfab4e4dc2702bc6ccc36038defd850837bd2/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/c33bfab4e4dc2702bc6ccc36038defd850837bd2/build/toolchain/win/BUILD.gn

Project Member

Comment 11 by bugdroid1@chromium.org, Apr 21 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0d539e12630324a0ab446b19cacf765761cf9684

commit 0d539e12630324a0ab446b19cacf765761cf9684
Author: jbudorick <jbudorick@chromium.org>
Date: Thu Apr 21 01:04:45 2016

Revert of Implement arflags in the GN build. (patchset #2 id:20001 of https://codereview.chromium.org/1896163003/ )

Reason for revert:
variety of compile failures on Android bots that have been switched to GN, see https://codereview.chromium.org/1896163003/#msg18

Original issue's description:
> Implement arflags in the GN build.
>
> This flag was recently added in GN. This patch hooks it up to the toolchains
> and moves some flags to use it that previously had to be hardcoded on the
> tool command itself.
>
> Remove concurrent_links variable from gcc_toolchain which was unused.
>
> BUG= 598599 

TBR=brucedawson@chromium.org,brettw@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 598599 

Review URL: https://codereview.chromium.org/1903363003

Cr-Commit-Position: refs/heads/master@{#388646}

[modify] https://crrev.com/0d539e12630324a0ab446b19cacf765761cf9684/build/config/compiler/BUILD.gn
[modify] https://crrev.com/0d539e12630324a0ab446b19cacf765761cf9684/build/config/win/BUILD.gn
[modify] https://crrev.com/0d539e12630324a0ab446b19cacf765761cf9684/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/0d539e12630324a0ab446b19cacf765761cf9684/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/0d539e12630324a0ab446b19cacf765761cf9684/build/toolchain/win/BUILD.gn

Project Member

Comment 12 by bugdroid1@chromium.org, Apr 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/920a09e4e58f92bf1ece1fcf1f31ec44185a4959

commit 920a09e4e58f92bf1ece1fcf1f31ec44185a4959
Author: brettw <brettw@chromium.org>
Date: Fri Apr 22 00:22:47 2016

Implement arflags in the GN build.

This flag was recently added in GN. This patch hooks it up to the toolchains
and moves some flags to use it that previously had to be hardcoded on the
tool command itself.

Remove concurrent_links variable from gcc_toolchain which was unused.

BUG= 598599 
Reland of http://crrev.com/1896163003 with fix.

Review URL: https://codereview.chromium.org/1909163002

Cr-Commit-Position: refs/heads/master@{#388971}

[modify] https://crrev.com/920a09e4e58f92bf1ece1fcf1f31ec44185a4959/build/config/compiler/BUILD.gn
[modify] https://crrev.com/920a09e4e58f92bf1ece1fcf1f31ec44185a4959/build/config/posix/BUILD.gn
[modify] https://crrev.com/920a09e4e58f92bf1ece1fcf1f31ec44185a4959/build/config/win/BUILD.gn
[modify] https://crrev.com/920a09e4e58f92bf1ece1fcf1f31ec44185a4959/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/920a09e4e58f92bf1ece1fcf1f31ec44185a4959/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/920a09e4e58f92bf1ece1fcf1f31ec44185a4959/build/toolchain/win/BUILD.gn

The arflags aren't getting passed to lib.exe on Windows builds. I just grabbed ToT and hit these warnings (many repetitions elided):

C:\src\chromium3\src>ninja -v -d keeprsp -C out\Debug_gn_component mesa
ninja: Entering directory `out\Debug_gn_component'
[1 processes, 0/1 @ ?/s : 0.000s ] C:/python_27_amd64/files/python.exe gyp-win-tool link-wrapper environment.x86 False lib.exe /nologo  /OUT:obj/third_party/mesa/mesa.lib @obj/third_party/mesa/mesa.lib.rsp
m_debug_xform.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
m_debug_norm.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
...

Examining the .rsp file confirms that there is no /ignore:4221 option being passed. Thoughts on how to diagnose?

Project Member

Comment 14 by bugdroid1@chromium.org, Apr 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2ce39e29422675764e94de94458ce3bb22fe53d3

commit 2ce39e29422675764e94de94458ce3bb22fe53d3
Author: jbudorick <jbudorick@chromium.org>
Date: Fri Apr 22 02:17:35 2016

Revert of Implement arflags in the GN build. (patchset #2 id:20001 of https://codereview.chromium.org/1909163002/ )

Reason for revert:
speculatively reverting: issues with linking on the gpu bots again: https://build.chromium.org/p/chromium.gpu/builders/Android%20Debug%20%28Nexus%206%29/builds/8079

Original issue's description:
> Implement arflags in the GN build.
>
> This flag was recently added in GN. This patch hooks it up to the toolchains
> and moves some flags to use it that previously had to be hardcoded on the
> tool command itself.
>
> Remove concurrent_links variable from gcc_toolchain which was unused.
>
> BUG= 598599 
> Reland of http://crrev.com/1896163003 with fix.

TBR=brucedawson@chromium.org,brettw@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 598599 

Review URL: https://codereview.chromium.org/1910393002

Cr-Commit-Position: refs/heads/master@{#389000}

[modify] https://crrev.com/2ce39e29422675764e94de94458ce3bb22fe53d3/build/config/compiler/BUILD.gn
[modify] https://crrev.com/2ce39e29422675764e94de94458ce3bb22fe53d3/build/config/posix/BUILD.gn
[modify] https://crrev.com/2ce39e29422675764e94de94458ce3bb22fe53d3/build/config/win/BUILD.gn
[modify] https://crrev.com/2ce39e29422675764e94de94458ce3bb22fe53d3/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/2ce39e29422675764e94de94458ce3bb22fe53d3/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/2ce39e29422675764e94de94458ce3bb22fe53d3/build/toolchain/win/BUILD.gn

Project Member

Comment 17 by bugdroid1@chromium.org, Apr 28 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/897cde76d084732227ea88af76163e33eda18778

commit 897cde76d084732227ea88af76163e33eda18778
Author: brettw <brettw@chromium.org>
Date: Thu Apr 28 18:21:09 2016

Implement arflags in the GN build.

This flag was recently added in GN. This patch hooks it up to the toolchains
and moves some flags to use it that previously had to be hardcoded on the
tool command itself.

Remove concurrent_links variable from gcc_toolchain which was unused.

BUG= 598599 
Reland of http://crrev.com/1909163002 with no changes (now that a GN binary push to fix the bug has gone in) which was a reland of http://crrev.com/1896163003 with fix.

Review-Url: https://codereview.chromium.org/1907403002
Cr-Commit-Position: refs/heads/master@{#390424}

[modify] https://crrev.com/897cde76d084732227ea88af76163e33eda18778/build/config/compiler/BUILD.gn
[modify] https://crrev.com/897cde76d084732227ea88af76163e33eda18778/build/config/posix/BUILD.gn
[modify] https://crrev.com/897cde76d084732227ea88af76163e33eda18778/build/config/win/BUILD.gn
[modify] https://crrev.com/897cde76d084732227ea88af76163e33eda18778/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/897cde76d084732227ea88af76163e33eda18778/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/897cde76d084732227ea88af76163e33eda18778/build/toolchain/win/BUILD.gn

Project Member

Comment 18 by bugdroid1@chromium.org, Apr 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/500a5624ab6d616b503bf75449cfc772b9c3d2c2

commit 500a5624ab6d616b503bf75449cfc772b9c3d2c2
Author: bpastene <bpastene@chromium.org>
Date: Fri Apr 29 00:39:26 2016

Revert of Implement arflags in the GN build. (patchset #4 id:60001 of https://codereview.chromium.org/1907403002/ )

Reason for revert:
As with the previous attempts to land this cl, android and GPU builders are failing compile with OOM errors:
https://bugs.chromium.org/p/chromium/issues/detail?id=607673

Original issue's description:
> Implement arflags in the GN build.
>
> This flag was recently added in GN. This patch hooks it up to the toolchains
> and moves some flags to use it that previously had to be hardcoded on the
> tool command itself.
>
> Remove concurrent_links variable from gcc_toolchain which was unused.
>
> BUG= 598599 
> Reland of http://crrev.com/1909163002 with no changes (now that a GN binary push to fix the bug has gone in) which was a reland of http://crrev.com/1896163003 with fix.

TBR=brucedawson@chromium.org,brettw@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 598599 

Review-Url: https://codereview.chromium.org/1930293002
Cr-Commit-Position: refs/heads/master@{#390545}

[modify] https://crrev.com/500a5624ab6d616b503bf75449cfc772b9c3d2c2/build/config/compiler/BUILD.gn
[modify] https://crrev.com/500a5624ab6d616b503bf75449cfc772b9c3d2c2/build/config/posix/BUILD.gn
[modify] https://crrev.com/500a5624ab6d616b503bf75449cfc772b9c3d2c2/build/config/win/BUILD.gn
[modify] https://crrev.com/500a5624ab6d616b503bf75449cfc772b9c3d2c2/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/500a5624ab6d616b503bf75449cfc772b9c3d2c2/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/500a5624ab6d616b503bf75449cfc772b9c3d2c2/build/toolchain/win/BUILD.gn

Project Member

Comment 19 by bugdroid1@chromium.org, Apr 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5404cdff57233dbad6e0b20afd547e445c57cd23

commit 5404cdff57233dbad6e0b20afd547e445c57cd23
Author: brettw <brettw@chromium.org>
Date: Fri Apr 29 23:10:39 2016

Implement arflags in the GN build.

This flag was recently added in GN. This patch hooks it up to the toolchains
and moves some flags to use it that previously had to be hardcoded on the
tool command itself.

Clarifies usage of concurrent_links variable in gcc_toolchain which was confusing.

TBR=brucedawson@chromium.org
BUG= 598599 
Reland of http://crrev.com/1909163002 with fixes which was a reland of http://crrev.com/1896163003 with fix.

Review-Url: https://codereview.chromium.org/1924203004
Cr-Commit-Position: refs/heads/master@{#390797}

[modify] https://crrev.com/5404cdff57233dbad6e0b20afd547e445c57cd23/build/config/compiler/BUILD.gn
[modify] https://crrev.com/5404cdff57233dbad6e0b20afd547e445c57cd23/build/config/posix/BUILD.gn
[modify] https://crrev.com/5404cdff57233dbad6e0b20afd547e445c57cd23/build/config/win/BUILD.gn
[modify] https://crrev.com/5404cdff57233dbad6e0b20afd547e445c57cd23/build/toolchain/gcc_toolchain.gni
[modify] https://crrev.com/5404cdff57233dbad6e0b20afd547e445c57cd23/build/toolchain/mac/BUILD.gn
[modify] https://crrev.com/5404cdff57233dbad6e0b20afd547e445c57cd23/build/toolchain/win/BUILD.gn

Sign in to add a comment