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") {
if (clang_use_chrome_plugins) {
cflags = []
# On Windows, the plugin is built directly into clang, so there's
# no need to load it 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),
]
}
# The plugin is built directly into clang, so there's no need to load it
# dynamically.
cflags += [
"-Xclang",
"-add-plugin",
......
......@@ -93,22 +93,8 @@ config("config") {
}
if (is_clang && blink_gc_plugin && clang_use_chrome_plugins) {
# On Windows, the plugin is built directly into clang, so there's
# no need to load it 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),
]
}
# The plugin is built directly into clang, so there's no need to load it
# dynamically.
cflags += [
"-Xclang",
"-add-plugin",
......
......@@ -15,35 +15,22 @@ set(plugin_sources
Edge.cpp
RecordInfo.cpp)
if(WIN32)
# Clang doesn't support loadable modules on Windows. Unfortunately, building
# 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
# strips it out completely.
# 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
# clang...
cmake_minimum_required(VERSION 3.1)
# Paths must be absolute, since we're modifying a target in another directory.
set(absolute_sources "")
foreach(source ${plugin_sources})
list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
endforeach()
set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
# Clang doesn't support loadable modules on Windows. Unfortunately, building
# 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
# strips it out completely.
# Instead, we rely on the fact that the SOURCES property of a target is not
# read-only after CMake 3.1 and use it to compile the plugin directly into
# clang.
cmake_minimum_required(VERSION 3.1)
# Paths must be absolute, since we're modifying a target in another directory.
set(absolute_sources "")
foreach(source ${plugin_sources})
list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
endforeach()
set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
cr_add_test(blink_gc_plugin_test
python tests/test.py
${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()
cr_add_test(blink_gc_plugin_test
python tests/test.py
${CMAKE_BINARY_DIR}/bin/clang
)
......@@ -49,15 +49,11 @@ def main():
action='store_true',
help='If specified, overwrites the expected results in place.')
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()
return BlinkGcPluginTest(
os.path.dirname(os.path.realpath(__file__)),
args.clang_path,
args.plugin_path,
'blink-gc-plugin',
args.reset_results).Run()
......
......@@ -6,35 +6,22 @@ set(plugin_sources
Util.cpp
)
if(WIN32)
# Clang doesn't support loadable modules on Windows. Unfortunately, building
# 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
# strips it out completely.
# 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
# clang...
cmake_minimum_required(VERSION 3.1)
# Paths must be absolute, since we're modifying a target in another directory.
set(absolute_sources "")
foreach(source ${plugin_sources})
list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
endforeach()
set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
# Clang doesn't support loadable modules on Windows. Unfortunately, building
# 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
# strips it out completely.
# Instead, we rely on the fact that the SOURCES property of a target is not
# read-only after CMake 3.1 and use it to compile the plugin directly into
# clang.
cmake_minimum_required(VERSION 3.1)
# Paths must be absolute, since we're modifying a target in another directory.
set(absolute_sources "")
foreach(source ${plugin_sources})
list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
endforeach()
set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})
cr_add_test(plugins_test
python tests/test.py
${CMAKE_BINARY_DIR}/bin/clang
cr_add_test(plugins_test
python tests/test.py
${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():
action='store_true',
help='If specified, overwrites the expected results in place.')
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()
return ChromeStylePluginTest(
os.path.dirname(os.path.realpath(__file__)),
args.clang_path,
args.plugin_path,
'find-bad-constructs',
args.reset_results).Run()
......
......@@ -12,22 +12,17 @@ import sys
class ClangPluginTest(object):
"""Test harness for clang plugins."""
def __init__(self, test_base, clang_path, plugin_path, plugin_name,
reset_results):
def __init__(self, test_base, clang_path, plugin_name, reset_results):
"""Constructor.
Args:
test_base: Path to the directory containing the tests.
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.
reset_results: If true, resets expected results to the actual test output.
"""
self._test_base = test_base
self._clang_path = clang_path
self._plugin_path = plugin_path
self._plugin_name = plugin_name
self._reset_results = reset_results
......@@ -49,13 +44,10 @@ class ClangPluginTest(object):
Returns: the number of failing tests.
"""
print 'Using clang %s...' % self._clang_path
print 'Using plugin %s...' % self._plugin_path
os.chdir(self._test_base)
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])
self.AdjustClangArguments(clang_cmd)
......
......@@ -242,11 +242,7 @@ def main():
want.append('bin/clang-cl.exe')
want.append('bin/lld-link.exe')
else:
so_ext = 'dylib' if sys.platform == 'darwin' else 'so'
want.extend(['bin/clang',
'lib/libFindBadConstructs.' + so_ext,
'lib/libBlinkGCPlugin.' + so_ext,
])
want.append('bin/clang')
if sys.platform == 'darwin':
want.extend([
# AddressSanitizer runtime.
......@@ -403,10 +399,7 @@ def main():
stripped_binaries.append('lld')
stripped_binaries.append('llvm-ar')
for f in stripped_binaries:
if sys.platform == 'darwin':
# See http://crbug.com/256342
subprocess.call(['strip', '-x', os.path.join(pdir, 'bin', f)])
elif sys.platform.startswith('linux'):
if sys.platform != 'win32':
subprocess.call(['strip', os.path.join(pdir, 'bin', f)])
# Set up symlinks.
......
......@@ -35,7 +35,7 @@ if use_head_revision:
CLANG_REVISION = 'HEAD'
# 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)
......@@ -532,6 +532,7 @@ def UpdateClang(args):
'-DLLVM_ENABLE_TERMINFO=OFF',
# Statically link MSVCRT to avoid DLL dependencies.
'-DLLVM_USE_CRT_RELEASE=MT',
'-DCLANG_PLUGIN_SUPPORT=OFF',
]
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