Ignore:
Timestamp:
Mar 7, 2022, 11:18:39 PM (3 years ago)
Author:
Elliott Williams
Message:

[XCBuild] Emit a discovered dependency file from offlineasm
https://bugs.webkit.org/show_bug.cgi?id=237329

Reviewed by Keith Miller.

Xcode needs to know what files offlineasm uses and produces in order to schedule it
correctly in incremental builds. Rather than use generated xcfilelists like WebKit does
elsewhere in the project, emit a depfile from offlineasm based on the parse tree's source
files.

Discovered dependency files ("depfiles") are Makefile-formatted files which list the inputs
used to produce an output. They are emitting during the build to a temporary directory, and
ensure that subsequent incremental builds will re-run offlineasm when any of the included
sources change. This is the same mechanism clang uses to track header dependencies.

Unfortunately, the legacy build system will refuse to execute a script phase or rule that
emits a depfile. To work around this, convert the offlineasm pipeline to be based on build
rules, to be used by XCBuild only. The idea is that LowLevelInterpreter.asm is listed as a
source build file in JSCLLIntSettingsExtractor, JSCLLIntOffsetsExtractor, and
JavaScriptCore. Each target uses a build rule to generate its respective header from
LowLevelInterpreter.asm. Xcode schedules these rule executions before any clang tasks.

The legacy build system avoids executing the rules via EXCLUDED_SOURCE_FILE_NAMES, and
instead uses the existing build phases, which have "(Legacy)" in their names and are now
no-ops under XCBuild.

Aside from working around the legacy build system's limitations, using build rules is
probably a superior way to express what we're doing, as it gives Xcode the opportunity to
compile other objects in parallel, and could be easily extended to compile multiple discrete
asm files should the need arise.

  • Configurations/ToolExecutable.xcconfig: Build rules are XCBuild-only.
  • JavaScriptCore.xcodeproj/project.pbxproj: Add build rules, rename legacy scripts.
  • offlineasm/asm.rb: Add --depfile flag.
  • offlineasm/generate_offset_extractor.rb: Add --depfile flag.
  • offlineasm/generate_settings_extractor.rb: Add --depfile flag.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/asm.rb

    r284868 r290975  
    3434require "self_hash"
    3535require "settings"
     36require "shellwords"
    3637require "transform"
    3738
     
    348349$options = {}
    349350OptionParser.new do |opts|
    350     opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>] [--webkit-additions-path=<path>] [--binary-format=<format>]"
     351    opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>] [--webkit-additions-path=<path>] [--binary-format=<format>] [--depfile=<depfile>]"
    351352    # This option is currently only used to specify the masm assembler
    352353    opts.on("--assembler=[ASM]", "Specify an assembler to use.") do |assembler|
     
    358359    opts.on("--binary-format=FORMAT", "Specify the binary format used by the target system.") do |format|
    359360        $options[:binary_format] = format
     361    end
     362    opts.on("--depfile=DEPFILE", "Path to write Makefile-style discovered dependencies to.") do |path|
     363        $options[:depfile] = path
    360364    end
    361365end.parse!
     
    385389    " " + Digest::SHA1.hexdigest($options.has_key?(:assembler) ? $options[:assembler] : "")
    386390
    387 if FileTest.exist? outputFlnm
     391if FileTest.exist?(outputFlnm) and (not $options[:depfile] or FileTest.exist?($options[:depfile]))
    388392    lastLine = nil
    389393    File.open(outputFlnm, "r") {
     
    408412
    409413    $asm = Assembler.new($output)
    410    
    411     ast = parse(asmFile, $options)
     414
     415    sources = Set.new
     416    ast = parse(asmFile, $options, sources)
    412417    settingsCombinations = computeSettingsCombinations(ast)
     418   
     419    if $options[:depfile]
     420        depfile = File.open($options[:depfile], "w")
     421        depfile.print(Shellwords.escape(outputFlnm), ": ")
     422        depfile.puts(Shellwords.join(sources.sort))
     423    end
    413424
    414425    configurationList.each {
Note: See TracChangeset for help on using the changeset viewer.