Changeset 254080 in webkit


Ignore:
Timestamp:
Jan 6, 2020, 12:58:44 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Add --force-optimization-level option to Tools/Scripts/set-webkit-configuration.
https://bugs.webkit.org/show_bug.cgi?id=205787

Reviewed by Saam Barati.

Usage:

--force-optimization-level=<opt> Force optimization: O3, O2, O1, O0, Os, Ofast, Og, or none

This can be used to force debug builds to be built with a higher level optimization
so that tests can run to completion faster.

It can also be useful as a simple way to force release builds to be built with
different optimization levels for performance comparison.

Setting --force-optimization-level=none restores the default optimization levels.
Of course, the build targets need to be rebuilt for this to take effect.

  • Scripts/set-webkit-configuration:
  • Scripts/webkitdirs.pm:

(determineForceOptimizationLevel):
(forceOptimizationLevel):
(XcodeOptions):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r254064 r254080  
     12020-01-06  Mark Lam  <mark.lam@apple.com>
     2
     3        Add --force-optimization-level option to Tools/Scripts/set-webkit-configuration.
     4        https://bugs.webkit.org/show_bug.cgi?id=205787
     5
     6        Reviewed by Saam Barati.
     7
     8        Usage:
     9            --force-optimization-level=<opt> Force optimization: O3, O2, O1, O0, Os, Ofast, Og, or none
     10
     11        This can be used to force debug builds to be built with a higher level optimization
     12        so that tests can run to completion faster.
     13
     14        It can also be useful as a simple way to force release builds to be built with
     15        different optimization levels for performance comparison.
     16
     17        Setting --force-optimization-level=none restores the default optimization levels.
     18        Of course, the build targets need to be rebuilt for this to take effect.
     19
     20        * Scripts/set-webkit-configuration:
     21        * Scripts/webkitdirs.pm:
     22        (determineForceOptimizationLevel):
     23        (forceOptimizationLevel):
     24        (XcodeOptions):
     25
    1262020-01-05  Dean Jackson  <dino@apple.com>
    227
  • trunk/Tools/Scripts/set-webkit-configuration

    r235381 r254080  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2005 Apple Inc.  All rights reserved.
     3# Copyright (C) 2005-2019 Apple Inc.  All rights reserved.
    44#
    55# Redistribution and use in source and binary forms, with or without
     
    3636my $usage = <<EOF;
    3737Usage: $programName [options]
    38   --32-bit                Set the default architecture to 32-bit
    39   --64-bit                Set the default architecture to 64-bit
    40   --[no-]asan             Enable or disable clang address sanitizer
    41   --lto-mode=<mode>       Set LTO mode: full, thin, or none
    42   --debug                 Set the default configuration to debug
    43   --release               Set the default configuration to release
    44   --reset                 Reset configurations
     38  --32-bit                           Set the default architecture to 32-bit
     39  --64-bit                           Set the default architecture to 64-bit
     40  --[no-]asan                        Enable or disable clang address sanitizer
     41  --force-optimization-level=<level> Optimization level: O3, O2, O1, O0, Os, Ofast, Og, or none
     42  --lto-mode=<mode>                  Set LTO mode: full, thin, or none
     43  --debug                            Set the default configuration to debug
     44  --release                          Set the default configuration to release
     45  --reset                            Reset configurations
    4546EOF
    4647
     
    5253if (!checkForArgumentAndRemoveFromARGVGettingValue("--lto-mode", \$ltoMode)) {
    5354    $ltoMode="";
     55}
     56my $forceOptimizationLevel;
     57if (!checkForArgumentAndRemoveFromARGVGettingValue("--force-optimization-level", \$forceOptimizationLevel)) {
     58    $forceOptimizationLevel="";
    5459}
    5560
     
    7277    unlink "$baseProductDir/Architecture";
    7378    unlink "$baseProductDir/ASan";
     79    unlink "$baseProductDir/ForceOptimizationLevel";
    7480    unlink "$baseProductDir/LTO";
    7581    exit 0;
    7682}
    7783
    78 if ((!$configuration && !$architecture && !$enableASAN && !$disableASAN && !$ltoMode) || ($enableASAN && $disableASAN)) {
     84if ((!$configuration && !$architecture && !$enableASAN && !$disableASAN && !$ltoMode && !$forceOptimizationLevel) || ($enableASAN && $disableASAN)) {
    7985    print STDERR $usage;
    8086    exit 1;
     
    8288
    8389if ($ltoMode && $ltoMode ne "full" && $ltoMode ne "thin" && $ltoMode ne "none") {
     90    print STDERR $usage;
     91    exit 1;
     92}
     93
     94if ($forceOptimizationLevel
     95    && $forceOptimizationLevel ne "none"
     96    && $forceOptimizationLevel ne "O0"
     97    && $forceOptimizationLevel ne "O1"
     98    && $forceOptimizationLevel ne "O2"
     99    && $forceOptimizationLevel ne "O3"
     100    && $forceOptimizationLevel ne "Os"
     101    && $forceOptimizationLevel ne "Ofast"
     102    && $forceOptimizationLevel ne "Og") {
    84103    print STDERR $usage;
    85104    exit 1;
     
    110129}
    111130
     131if ($forceOptimizationLevel && $forceOptimizationLevel eq "none") {
     132    unlink "$baseProductDir/ForceOptimizationLevel";
     133} elsif ($forceOptimizationLevel) {
     134    open ForceOptimizationLevel, ">", "$baseProductDir/ForceOptimizationLevel" or die;
     135    print ForceOptimizationLevel substr($forceOptimizationLevel, 1) . "\n";
     136    close ForceOptimizationLevel;
     137}
     138
    112139if ($ltoMode) {
    113140    open LTO, ">", "$baseProductDir/LTO" or die;
  • trunk/Tools/Scripts/webkitdirs.pm

    r253845 r254080  
    1 # Copyright (C) 2005-2007, 2010-2016 Apple Inc. All rights reserved.
     1# Copyright (C) 2005-2019 Apple Inc. All rights reserved.
    22# Copyright (C) 2009 Google Inc. All rights reserved.
    33# Copyright (C) 2011 Research In Motion Limited. All rights reserved.
     
    133133my $architecture;
    134134my $asanIsEnabled;
     135my $forceOptimizationLevel;
    135136my $ltoMode;
    136137my $numberOfCPUs;
     
    424425}
    425426
     427sub determineForceOptimizationLevel
     428{
     429    return if defined $forceOptimizationLevel;
     430    determineBaseProductDir();
     431
     432    if (open ForceOptimizationLevel, "$baseProductDir/ForceOptimizationLevel") {
     433        $forceOptimizationLevel = <ForceOptimizationLevel>;
     434        close ForceOptimizationLevel;
     435        chomp $forceOptimizationLevel;
     436    }
     437}
     438
    426439sub determineLTOMode
    427440{
     
    808821}
    809822
     823sub forceOptimizationLevel()
     824{
     825    determineForceOptimizationLevel();
     826    return $forceOptimizationLevel;
     827}
     828
    810829sub ltoMode()
    811830{
     
    856875    determineArchitecture();
    857876    determineASanIsEnabled();
     877    determineForceOptimizationLevel();
    858878    determineLTOMode();
    859879    determineXcodeSDK();
     
    864884    push @options, ("-configuration", $configuration);
    865885    push @options, ("-xcconfig", sourceDir() . "/Tools/asan/asan.xcconfig", "ASAN_IGNORE=" . sourceDir() . "/Tools/asan/webkit-asan-ignore.txt") if $asanIsEnabled;
     886    push @options, ("GCC_OPTIMIZATION_LEVEL=$forceOptimizationLevel") if $forceOptimizationLevel;
    866887    push @options, "WK_LTO_MODE=$ltoMode" if $ltoMode;
    867888    push @options, @baseProductDirOption;
Note: See TracChangeset for help on using the changeset viewer.