tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

moz.build (5431B)


      1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
      2 # vim: set filetype=python:
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 HostSharedLibrary("clang-plugin")
      8 
      9 HOST_SOURCES += ["!ThirdPartyPaths.cpp"]
     10 
     11 HOST_SOURCES += [
     12     "ArithmeticArgChecker.cpp",
     13     "AssertAssignmentChecker.cpp",
     14     "CanRunScriptChecker.cpp",
     15     "CustomAttributes.cpp",
     16     "CustomTypeAnnotation.cpp",
     17     "DanglingOnTemporaryChecker.cpp",
     18     "DiagnosticsMatcher.cpp",
     19     "ExplicitImplicitChecker.cpp",
     20     "ExplicitOperatorBoolChecker.cpp",
     21     "GlobalVariableInitializationChecker.cpp",
     22     "JSHandleRootedTypedefChecker.cpp",
     23     "KnownLiveChecker.cpp",
     24     "KungFuDeathGripChecker.cpp",
     25     "MozCheckAction.cpp",
     26     "MustOverrideChecker.cpp",
     27     "MustReturnFromCallerChecker.cpp",
     28     "NaNExprChecker.cpp",
     29     "NeedsNoVTableTypeChecker.cpp",
     30     "NoAddRefReleaseOnReturnChecker.cpp",
     31     "NoAutoTypeChecker.cpp",
     32     "NoDuplicateRefCntMemberChecker.cpp",
     33     "NoExplicitMoveConstructorChecker.cpp",
     34     "NoNewThreadsChecker.cpp",
     35     "NonMemMovableMemberChecker.cpp",
     36     "NonMemMovableTemplateArgChecker.cpp",
     37     "NonParamInsideFunctionDeclChecker.cpp",
     38     "NonTrivialTypeInFfiChecker.cpp",
     39     "NoPrincipalGetURI.cpp",
     40     "NoUsingNamespaceMozillaJavaChecker.cpp",
     41     "OverrideBaseCallChecker.cpp",
     42     "OverrideBaseCallUsageChecker.cpp",
     43     "ParamTraitsEnumChecker.cpp",
     44     "RefCountedCopyConstructorChecker.cpp",
     45     "RefCountedInsideLambdaChecker.cpp",
     46     "RefCountedThisInsideConstructorChecker.cpp",
     47     "ScopeChecker.cpp",
     48     "SprintfLiteralChecker.cpp",
     49     "TrivialCtorDtorChecker.cpp",
     50     "TrivialDtorChecker.cpp",
     51     "VariableUsageHelpers.cpp",
     52 ]
     53 
     54 # Ideally, we wouldn't have compile-time choices wrt checks. bug 1617153.
     55 if CONFIG["OS_ARCH"] == "WINNT":
     56     HOST_DEFINES["TARGET_IS_WINDOWS"] = True
     57     HOST_SOURCES += [
     58         "FopenUsageChecker.cpp",
     59         "LoadLibraryUsageChecker.cpp",
     60     ]
     61 
     62 if CONFIG["ENABLE_MOZSEARCH_PLUGIN"]:
     63     HOST_SOURCES += [
     64         "mozsearch-plugin/BindingOperations.cpp",
     65         "mozsearch-plugin/FileOperations.cpp",
     66         "mozsearch-plugin/from-clangd/HeuristicResolver.cpp",
     67         "mozsearch-plugin/MozsearchIndexer.cpp",
     68         "mozsearch-plugin/StringOperations.cpp",
     69     ]
     70 
     71 GeneratedFile(
     72     "ThirdPartyPaths.cpp",
     73     script="ThirdPartyPaths.py",
     74     entry_point="generate",
     75     inputs=[
     76         "/tools/rewriting/ThirdPartyPaths.txt",
     77         "/tools/rewriting/Generated.txt",
     78     ],
     79 )
     80 
     81 GeneratedFile(
     82     "ThreadAllows.h",
     83     script="ThreadAllows.py",
     84     entry_point="generate_file",
     85     inputs=[
     86         "/build/clang-plugin/ThreadAllows.txt",
     87         "/build/clang-plugin/ThreadFileAllows.txt",
     88     ],
     89 )
     90 
     91 HOST_COMPILE_FLAGS["STL"] = []
     92 HOST_COMPILE_FLAGS["VISIBILITY"] = []
     93 
     94 HOST_LDFLAGS += CONFIG["LLVM_LDFLAGS"]
     95 
     96 # libc++ is required to build plugins against clang on OS X.
     97 if CONFIG["HOST_OS_ARCH"] == "Darwin":
     98     HOST_CXXFLAGS += ["-stdlib=libc++"]
     99 
    100     # We need to make sure that we use the symbols coming from the clang
    101     # binary. In order to do this, we need to pass -flat_namespace and
    102     # -undefined suppress to the linker. This makes sure that we link the
    103     # symbols into the flat namespace provided by clang, and thus get
    104     # access to all of the symbols which are undefined in our dylib as we
    105     # are building it right now, and also that we don't fail the build
    106     # due to undefined symbols (which will be provided by clang).
    107     HOST_LDFLAGS += ["-Wl,-flat_namespace", "-Wl,-undefined,suppress"]
    108 
    109 # As of clang 8, llvm-config doesn't output the flags used to build clang
    110 # itself, so we don't end up with -fPIC as a side effect. llvm.org/PR8220
    111 if CONFIG["HOST_OS_ARCH"] != "WINNT":
    112     HOST_CXXFLAGS += ["-fPIC"]
    113     HOST_LDFLAGS += ["-shared"]
    114 else:
    115     # clang-plugin.dll needs to be deterministic for sccache hashes
    116     HOST_LDFLAGS += ["-brepro"]
    117 
    118 TEST_DIRS += [
    119     "tests",
    120 ]
    121 
    122 include("external/sources.mozbuild")
    123 
    124 if CONFIG["ENABLE_CLANG_PLUGIN_ALPHA"]:
    125     HOST_DEFINES["MOZ_CLANG_PLUGIN_ALPHA"] = "1"
    126     include("alpha/sources.mozbuild")
    127 
    128 # In the current moz.build world, we need to override essentially every
    129 # variable to limit ourselves to what we need to build the clang plugin.
    130 if CONFIG["HOST_OS_ARCH"] == "WINNT":
    131     extra_cxxflags = ["-GR-", "-EHsc"]
    132     # Clang 14 headers enforce a requirement upon Visual Studio 2019 headers,
    133     # for support of newer C++ versions, which is necessary for clang itself,
    134     # but as of writing, it's not necessary for the plugin code, so enable
    135     # the escape hatch, at least until we generally upgrade to VS 2019.
    136     HOST_DEFINES["LLVM_FORCE_USE_OLD_TOOLCHAIN"] = True
    137     # Clang 20+ needs /Zc:dllexportInlines- to work around CLANG_ABI issues with inline methods
    138     if CONFIG["HOST_CC_VERSION"] and int(CONFIG["HOST_CC_VERSION"].split(".")[0]) >= 20:
    139         extra_cxxflags += ["/Zc:dllexportInlines-"]
    140 else:
    141     extra_cxxflags = ["-fno-rtti", "-fno-exceptions"]
    142 
    143 if CONFIG["LLVM_CXXFLAGS"]:
    144     HOST_COMPILE_FLAGS["HOST_CXXFLAGS"] = CONFIG["LLVM_CXXFLAGS"] + extra_cxxflags
    145 
    146 # Avoid -DDEBUG=1 on the command line, which conflicts with a #define
    147 # DEBUG(...) in llvm headers.
    148 DEFINES["DEBUG"] = False
    149 
    150 HOST_OS_LIBS += ["clangASTMatchers"]
    151 if CONFIG["HOST_OS_ARCH"] == "WINNT":
    152     HOST_OS_LIBS += ["clang"]