Commit 25a9c5ec authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

Build clang without plugin support.

See bug for details.

Bug: 917404,256342
Change-Id: Ic5fd959f23e77b9194af4faecceeefffe0b924ae
Reviewed-on: https://chromium-review.googlesource.com/c/1387395
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarReid Kleckner <rnk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619595}
parent db42060a
...@@ -8,26 +8,8 @@ config("find_bad_constructs") { ...@@ -8,26 +8,8 @@ config("find_bad_constructs") {
if (clang_use_chrome_plugins) { if (clang_use_chrome_plugins) {
cflags = [] cflags = []
# On Windows, the plugin is built directly into clang, so there's # The plugin is built directly into clang, so there's no need to load it
# no need to load it dynamically. # dynamically.
if (host_os == "mac") {
cflags += [
"-Xclang",
"-load",
"-Xclang",
rebase_path("${clang_base_path}/lib/libFindBadConstructs.dylib",
root_build_dir),
]
} else if (host_os == "linux") {
cflags += [
"-Xclang",
"-load",
"-Xclang",
rebase_path("${clang_base_path}/lib/libFindBadConstructs.so",
root_build_dir),
]
}
cflags += [ cflags += [
"-Xclang", "-Xclang",
"-add-plugin", "-add-plugin",
......
...@@ -93,22 +93,8 @@ config("config") { ...@@ -93,22 +93,8 @@ config("config") {
} }
if (is_clang && blink_gc_plugin && clang_use_chrome_plugins) { if (is_clang && blink_gc_plugin && clang_use_chrome_plugins) {
# On Windows, the plugin is built directly into clang, so there's # The plugin is built directly into clang, so there's no need to load it
# no need to load it dynamically. # dynamically.
if (host_os != "win") {
_blink_gc_plugin_dll_extension = "so"
if (host_os == "mac") {
_blink_gc_plugin_dll_extension = "dylib"
}
cflags += [
"-Xclang",
"-load",
"-Xclang",
rebase_path(
"${clang_base_path}/lib/libBlinkGCPlugin.${_blink_gc_plugin_dll_extension}",
root_build_dir),
]
}
cflags += [ cflags += [
"-Xclang", "-Xclang",
"-add-plugin", "-add-plugin",
......
...@@ -15,35 +15,22 @@ set(plugin_sources ...@@ -15,35 +15,22 @@ set(plugin_sources
Edge.cpp Edge.cpp
RecordInfo.cpp) RecordInfo.cpp)
if(WIN32) # Clang doesn't support loadable modules on Windows. Unfortunately, building
# Clang doesn't support loadable modules on Windows. Unfortunately, building # the plugin as a static library and linking clang against it doesn't work.
# the plugin as a static library and linking clang against it doesn't work. # Since clang doesn't reference any symbols in our static library, the linker
# Since clang doesn't reference any symbols in our static library, the linker # strips it out completely.
# strips it out completely. # Instead, we rely on the fact that the SOURCES property of a target is not
# Instead, we rely on the fact that the SOURCES property of a target is no # read-only after CMake 3.1 and use it to compile the plugin directly into
# read-only after CMake 3.1 and use it to compile the plugin directly into # clang.
# clang... cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1) # Paths must be absolute, since we're modifying a target in another directory.
# Paths must be absolute, since we're modifying a target in another directory. set(absolute_sources "")
set(absolute_sources "") foreach(source ${plugin_sources})
foreach(source ${plugin_sources}) list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source}) endforeach()
endforeach() set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
cr_add_test(blink_gc_plugin_test cr_add_test(blink_gc_plugin_test
python tests/test.py python tests/test.py
${CMAKE_BINARY_DIR}/bin/clang ${CMAKE_BINARY_DIR}/bin/clang
) )
else()
add_llvm_library("lib${LIBRARYNAME}" MODULE ${plugin_sources})
add_dependencies("lib${LIBRARYNAME}" clang)
cr_install(TARGETS "lib${LIBRARYNAME}" LIBRARY DESTINATION lib)
cr_add_test(blink_gc_plugin_test
python tests/test.py
${CMAKE_BINARY_DIR}/bin/clang
$<TARGET_FILE:lib${LIBRARYNAME}>
)
endif()
...@@ -49,15 +49,11 @@ def main(): ...@@ -49,15 +49,11 @@ def main():
action='store_true', action='store_true',
help='If specified, overwrites the expected results in place.') help='If specified, overwrites the expected results in place.')
parser.add_argument('clang_path', help='The path to the clang binary.') parser.add_argument('clang_path', help='The path to the clang binary.')
parser.add_argument('plugin_path',
nargs='?',
help='The path to the plugin library, if any.')
args = parser.parse_args() args = parser.parse_args()
return BlinkGcPluginTest( return BlinkGcPluginTest(
os.path.dirname(os.path.realpath(__file__)), os.path.dirname(os.path.realpath(__file__)),
args.clang_path, args.clang_path,
args.plugin_path,
'blink-gc-plugin', 'blink-gc-plugin',
args.reset_results).Run() args.reset_results).Run()
......
...@@ -6,35 +6,22 @@ set(plugin_sources ...@@ -6,35 +6,22 @@ set(plugin_sources
Util.cpp Util.cpp
) )
if(WIN32) # Clang doesn't support loadable modules on Windows. Unfortunately, building
# Clang doesn't support loadable modules on Windows. Unfortunately, building # the plugin as a static library and linking clang against it doesn't work.
# the plugin as a static library and linking clang against it doesn't work. # Since clang doesn't reference any symbols in our static library, the linker
# Since clang doesn't reference any symbols in our static library, the linker # strips it out completely.
# strips it out completely. # Instead, we rely on the fact that the SOURCES property of a target is not
# Instead, we rely on the fact that the SOURCES property of a target is no # read-only after CMake 3.1 and use it to compile the plugin directly into
# read-only after CMake 3.1 and use it to compile the plugin directly into # clang.
# clang... cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.1) # Paths must be absolute, since we're modifying a target in another directory.
# Paths must be absolute, since we're modifying a target in another directory. set(absolute_sources "")
set(absolute_sources "") foreach(source ${plugin_sources})
foreach(source ${plugin_sources}) list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source}) endforeach()
endforeach() set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
cr_add_test(plugins_test cr_add_test(plugins_test
python tests/test.py python tests/test.py
${CMAKE_BINARY_DIR}/bin/clang ${CMAKE_BINARY_DIR}/bin/clang
) )
else()
add_llvm_library(libFindBadConstructs MODULE ${plugin_sources})
add_dependencies(libFindBadConstructs clang)
cr_install(TARGETS libFindBadConstructs LIBRARY DESTINATION lib)
cr_add_test(plugins_test
python tests/test.py
${CMAKE_BINARY_DIR}/bin/clang
$<TARGET_FILE:libFindBadConstructs>
)
endif()
...@@ -35,15 +35,11 @@ def main(): ...@@ -35,15 +35,11 @@ def main():
action='store_true', action='store_true',
help='If specified, overwrites the expected results in place.') help='If specified, overwrites the expected results in place.')
parser.add_argument('clang_path', help='The path to the clang binary.') parser.add_argument('clang_path', help='The path to the clang binary.')
parser.add_argument('plugin_path',
nargs='?',
help='The path to the plugin library, if any.')
args = parser.parse_args() args = parser.parse_args()
return ChromeStylePluginTest( return ChromeStylePluginTest(
os.path.dirname(os.path.realpath(__file__)), os.path.dirname(os.path.realpath(__file__)),
args.clang_path, args.clang_path,
args.plugin_path,
'find-bad-constructs', 'find-bad-constructs',
args.reset_results).Run() args.reset_results).Run()
......
...@@ -12,22 +12,17 @@ import sys ...@@ -12,22 +12,17 @@ import sys
class ClangPluginTest(object): class ClangPluginTest(object):
"""Test harness for clang plugins.""" """Test harness for clang plugins."""
def __init__(self, test_base, clang_path, plugin_path, plugin_name, def __init__(self, test_base, clang_path, plugin_name, reset_results):
reset_results):
"""Constructor. """Constructor.
Args: Args:
test_base: Path to the directory containing the tests. test_base: Path to the directory containing the tests.
clang_path: Path to the clang binary. clang_path: Path to the clang binary.
plugin_path: Optional path to the plugin binary. May be None, such as on
Windows, where the plugin is built directly into the clang
binary.
plugin_name: Name of the plugin. plugin_name: Name of the plugin.
reset_results: If true, resets expected results to the actual test output. reset_results: If true, resets expected results to the actual test output.
""" """
self._test_base = test_base self._test_base = test_base
self._clang_path = clang_path self._clang_path = clang_path
self._plugin_path = plugin_path
self._plugin_name = plugin_name self._plugin_name = plugin_name
self._reset_results = reset_results self._reset_results = reset_results
...@@ -49,13 +44,10 @@ class ClangPluginTest(object): ...@@ -49,13 +44,10 @@ class ClangPluginTest(object):
Returns: the number of failing tests. Returns: the number of failing tests.
""" """
print 'Using clang %s...' % self._clang_path print 'Using clang %s...' % self._clang_path
print 'Using plugin %s...' % self._plugin_path
os.chdir(self._test_base) os.chdir(self._test_base)
clang_cmd = [self._clang_path, '-c', '-std=c++14'] clang_cmd = [self._clang_path, '-c', '-std=c++14']
if self._plugin_path:
clang_cmd.extend(['-Xclang', '-load', '-Xclang', self._plugin_path])
clang_cmd.extend(['-Xclang', '-add-plugin', '-Xclang', self._plugin_name]) clang_cmd.extend(['-Xclang', '-add-plugin', '-Xclang', self._plugin_name])
self.AdjustClangArguments(clang_cmd) self.AdjustClangArguments(clang_cmd)
......
...@@ -242,11 +242,7 @@ def main(): ...@@ -242,11 +242,7 @@ def main():
want.append('bin/clang-cl.exe') want.append('bin/clang-cl.exe')
want.append('bin/lld-link.exe') want.append('bin/lld-link.exe')
else: else:
so_ext = 'dylib' if sys.platform == 'darwin' else 'so' want.append('bin/clang')
want.extend(['bin/clang',
'lib/libFindBadConstructs.' + so_ext,
'lib/libBlinkGCPlugin.' + so_ext,
])
if sys.platform == 'darwin': if sys.platform == 'darwin':
want.extend([ want.extend([
# AddressSanitizer runtime. # AddressSanitizer runtime.
...@@ -403,10 +399,7 @@ def main(): ...@@ -403,10 +399,7 @@ def main():
stripped_binaries.append('lld') stripped_binaries.append('lld')
stripped_binaries.append('llvm-ar') stripped_binaries.append('llvm-ar')
for f in stripped_binaries: for f in stripped_binaries:
if sys.platform == 'darwin': if sys.platform != 'win32':
# See http://crbug.com/256342
subprocess.call(['strip', '-x', os.path.join(pdir, 'bin', f)])
elif sys.platform.startswith('linux'):
subprocess.call(['strip', os.path.join(pdir, 'bin', f)]) subprocess.call(['strip', os.path.join(pdir, 'bin', f)])
# Set up symlinks. # Set up symlinks.
......
...@@ -35,7 +35,7 @@ if use_head_revision: ...@@ -35,7 +35,7 @@ if use_head_revision:
CLANG_REVISION = 'HEAD' CLANG_REVISION = 'HEAD'
# This is incremented when pushing a new build of Clang at the same revision. # This is incremented when pushing a new build of Clang at the same revision.
CLANG_SUB_REVISION=1 CLANG_SUB_REVISION=2
PACKAGE_VERSION = "%s-%s" % (CLANG_REVISION, CLANG_SUB_REVISION) PACKAGE_VERSION = "%s-%s" % (CLANG_REVISION, CLANG_SUB_REVISION)
...@@ -532,6 +532,7 @@ def UpdateClang(args): ...@@ -532,6 +532,7 @@ def UpdateClang(args):
'-DLLVM_ENABLE_TERMINFO=OFF', '-DLLVM_ENABLE_TERMINFO=OFF',
# Statically link MSVCRT to avoid DLL dependencies. # Statically link MSVCRT to avoid DLL dependencies.
'-DLLVM_USE_CRT_RELEASE=MT', '-DLLVM_USE_CRT_RELEASE=MT',
'-DCLANG_PLUGIN_SUPPORT=OFF',
] ]
if sys.platform != 'win32': if sys.platform != 'win32':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment