Ignore:
Timestamp:
Mar 10, 2022, 6:35:06 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 Alexey Proskuryakov.

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/parser.rb

    r290990 r291142  
    261261
    262262class Parser
    263     def initialize(data, fileName, options)
     263    def initialize(data, fileName, options, sources=nil)
    264264        @tokens = lex(data, fileName)
    265265        @idx = 0
     
    269269        @buildProductsDirectory = ENV['BUILT_PRODUCTS_DIR'];
    270270        @options = options
     271        @sources = sources
    271272    end
    272273   
     
    844845                fileExists = File.exists?(fileName)
    845846                raise "File not found: #{fileName}" if not fileExists and not isOptional
    846                 list << parse(fileName, @options) if fileExists
     847                list << parse(fileName, @options, @sources) if fileExists
    847848            else
    848849                parseError "Expecting terminal #{final} #{comment}"
     
    901902end
    902903
    903 def parseData(data, fileName, options)
    904     parser = Parser.new(data, SourceFile.new(fileName), options)
     904def parseData(data, fileName, options, sources)
     905    parser = Parser.new(data, SourceFile.new(fileName), options, sources)
    905906    parser.parseSequence(nil, "")
    906907end
    907908
    908 def parse(fileName, options)
    909     parseData(readTextFile(fileName), fileName, options)
     909def parse(fileName, options, sources=nil)
     910    sources << fileName if sources
     911    parseData(readTextFile(fileName), fileName, options, sources)
    910912end
    911913
Note: See TracChangeset for help on using the changeset viewer.