How to make a new default config? I don’t see how to practically do it

41 views
Skip to first unread message

Avi Drissman

unread,
Jul 12, 2023, 7:32:44 PM7/12/23
to gn-dev
Right now, ARC compilation for the Mac is a config, “//build/config/compiler:enable_arc”. It’s enabled for ~800 targets, and not enabled for 5 targets. That’s an understandable result of an incremental migration, but a bad situation to be in; for something that prevalent, we want to have it enabled globally and disabled for the handful of targets that don’t want it. That’s the situation that I want to end up at.

Plan A: Step 1: In a CL, add “enable_arc” to build/config/BUILDCONFIG.gn’s default_compiler_configs, and in 5 targets remove it. Step 2: take time to go through all the 800 targets that explicitly add “enable_arc”, and remove it as it’s redundant with the global config.

That doesn’t work. GN doesn’t like when you have the same config applied twice to a target.

OK, plan B: Step 1: In a CL, create an “enable_arc2” duplicate of “enable_arc”, and add that to the default config set while subtracting it from the config set of the handful of targets that don’t want it. Step 2: remove all the “enable_arc” configs. Step 3: rename “enable_arc2” to “enable_arc”.

That would work, but there are at least four different /third_party directories whose BUILD.gn files live in external repos (/third_party/angle, /third_party/dawn, /third_party/skia, /third_party/swiftshader). They depend on /build. Therefore I would need to do a “config -= [ “enable_arc2” ]” in each of them.

But there’s a problem. AngleDawnSkia, and SwiftShader are autorolled. For each of them, I can prepare a CL in that external repo that depends on “enable_arc2” but if the roll happens before the change in the Chromium repo lands, then the build will fail because the rolled version of the external dep will be referring to a non-existent config. If the roll happens after the change in the Chromium repo lands, then the Chromium change will fail because we’d be building the dep in a configuration it doesn’t support. And I can’t hold up four different autorolled external dependencies to do a coordinated commit across five repos.

While gn’s enforcement of not allowing a config to be added twice to a list is a pain that I can work around, I don’t see how to work around its enforcement of not allowing a config to be removed from a list that doesn’t contain it. I don’t see how to do large scale migrations in situations where the BUILD.gn file is deps-ed in from the outside.

Is it possible to do “remove this config from the list of configs if it exists and do nothing if not”? Is it possible to add that capability to gn, even if it’s immediately removed afterwards? What I’m doing is not unreasonable: I’m trying to make the Mac/iOS build much cleaner, and gn’s strictness seems to make it impossible to get to the cleaner future we all want.

Thanks,

Avi

Avi Drissman

unread,
Jul 12, 2023, 7:50:09 PM7/12/23
to gn-dev
I got a suggestion from sun...@google.com (thanks) of a Plan C:

Step 1: Add an empty "enable_arc2" config to the global configs. Step 2: Wait for it to roll into all external deps. Step 3: Add "deps -= [ "enable_arc2"] to all the external deps. Step 4: Wait for all of them to autoroll. Step 5: Redefine "enable_arc2" to enable ARC. Step 6: etc...

With a similar set of extra steps during the rename from "enable_arc2" to "enable_arc".

I guess that would work? Thoughts?

Avi

--
To unsubscribe from this topic, visit https://groups.google.com/a/chromium.org/d/topic/gn-dev/3r4cEkAJ870/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gn-dev+un...@chromium.org.

Tomasz Sniatowski

unread,
Jul 13, 2023, 2:02:53 AM7/13/23
to Avi Drissman, gn-dev
Hi!

There's a filter_include trick that can -= a config if it's there, I found one existing usage at https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/BUILD.gn;l=420

    # Only attempt to remove the 'default_optimization' label if it is already
    # present in 'configs'.
    if (filter_include(configs,
                       [ "//build/config/compiler:default_optimization" ]) !=
        []) {
      configs -= [ "//build/config/compiler:default_optimization" ]
    }

Seems like it could save some steps.

--
Tomasz Śniatowski

From: Avi Drissman <a...@chromium.org>
Sent: Thursday, July 13, 2023 01:32
To: gn-dev <gn-...@chromium.org>
Subject: How to make a new default config? I don’t see how to practically do it
 
 

This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email. For any questions don't hesitate to reach out to secu...@xperi.com


--
To unsubscribe from this group and stop receiving emails from it, send an email to gn-dev+un...@chromium.org.

Avi Drissman

unread,
Jul 13, 2023, 10:14:40 AM7/13/23
to Tomasz Sniatowski, gn-dev
!!!

That's a wonderful snippet! Thank you, this should make things a lot simpler.

Avi

Basic email

unread,
Jul 15, 2023, 3:01:43 PM7/15/23
to Avi Drissman, gn-dev
I hope u enjoy urself   I hope u have a valid warrent for 4 yrs of controlling my phone.  And filtering my calls. Emails browser  putting me in mentorship fb groups  and throwing me out of window s when I seek it and legal advice  

--

Basic email

unread,
Jul 15, 2023, 3:04:11 PM7/15/23
to gn-dev

Basic email

unread,
Jul 15, 2023, 3:24:03 PM7/15/23
to Avi Drissman, Tomasz Sniatowski, gn-dev
 I have but u use Google lens to edit every video put me in a  mentorship  group I hope u have a warrent   to  silence regular citizens it really wasn't to u bc u  are just building the program it was to the  person who is building creating and fabricating information it was the person assuming my identity  and using Google docs  word games to post as my self   enjoy  and gob bless

Avi Drissman

unread,
Jul 17, 2023, 5:54:02 PM7/17/23
to Tomasz Sniatowski, gn-dev
An issue with Swiftshader.

I have an .mm file in a swiftshader_source_set, and if I play the filter_include game it can't find the configs:

ERROR at //third_party/swiftshader/src/WSI/BUILD.gn:79:24: Undefined identifier
    if (filter_include(configs,
                       ^------
See //third_party/swiftshader/src/Vulkan/BUILD.gn:218:5: which caused the file to be included.
    "../WSI",
    ^-------
FAILED: build.ninja.stamp

swiftshader_source_set seems to be using the old-style "configs to add/remove" scheme. Is there a way to query what configs there are so that I can optionally remove the ones I don't want?

Avi

Tomasz Sniatowski

unread,
Jul 18, 2023, 2:52:27 AM7/18/23
to Avi Drissman, gn-dev
Can you do the filter_include "remove new config if it's there" dance in template("swiftshader_source_set"), in the source_set there -- for all of swiftshader?

--
Tomasz Śniatowski

From: Avi Drissman <a...@chromium.org>
Sent: Monday, July 17, 2023 23:53
To: Tomasz Sniatowski <tsnia...@vewd.com>
Cc: gn-dev <gn-...@chromium.org>
Subject: Re: How to make a new default config? I don’t see how to practically do it
 
Reply all
Reply to author
Forward
0 new messages