From 5a28312429e4fe14dd339b0acdf2f9a99ba07477 Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Wed, 13 Jun 2018 18:18:05 -0700 Subject: [PATCH] remove glibc, and remove executable step from native subsystem tests --- .../native/subsystems/native_toolchain.py | 21 ++---------- .../platform_specific/linux/glibc.py | 19 ----------- .../pants/backend/python/tasks/setup_py.py | 8 ++--- .../backend/native/subsystems/BUILD | 1 + .../subsystems/test_native_toolchain.py | 32 ++++++++----------- 5 files changed, 19 insertions(+), 62 deletions(-) delete mode 100644 src/python/pants/backend/native/subsystems/platform_specific/linux/glibc.py diff --git a/src/python/pants/backend/native/subsystems/native_toolchain.py b/src/python/pants/backend/native/subsystems/native_toolchain.py index 5c6220b5a50a..4851e1f2cbd3 100644 --- a/src/python/pants/backend/native/subsystems/native_toolchain.py +++ b/src/python/pants/backend/native/subsystems/native_toolchain.py @@ -9,11 +9,10 @@ from pants.backend.native.subsystems.llvm import LLVM from pants.backend.native.subsystems.platform_specific.darwin.xcode_cli_tools import XCodeCLITools from pants.backend.native.subsystems.platform_specific.linux.binutils import Binutils -from pants.backend.native.subsystems.platform_specific.linux.glibc import GLibc from pants.binaries.binary_tool import ExecutablePathProvider from pants.subsystem.subsystem import Subsystem from pants.util.memo import memoized_method -from pants.util.osutil import get_normalized_os_name, get_os_name, normalize_os_name +from pants.util.osutil import get_os_name, normalize_os_name class NativeToolchain(Subsystem, ExecutablePathProvider): @@ -84,23 +83,7 @@ def _get_platform_specific_subsystems(cls): def subsystem_dependencies(cls): prev = super(NativeToolchain, cls).subsystem_dependencies() cur_platform_subsystems = cls._get_platform_specific_subsystems() - return prev + tuple(sub.scoped(cls) for sub in cur_platform_subsystems) + ( - GLibc.scoped(cls), - ) - - @memoized_method - def glibc_dir(self): - # FIXME: Once #5815 lands, the "compiler" datatype should be given a field for - # (DY)?LD_LIBRARY_PATH entries. GCC and LLVM should be made to depend on GLibc on Linux and - # provide glibc in the new library path field. This provides necessary files including crti.o - # that are not included in the compiler. - normalized_os_name = get_normalized_os_name() - if normalized_os_name == 'darwin': - return None - elif normalized_os_name == 'linux': - return GLibc.scoped_instance(self).lib_dir() - else: - raise self.UnsupportedPlatformError("unrecognized os name: {}".format(normalized_os_name)) + return prev + tuple(sub.scoped(cls) for sub in cur_platform_subsystems) @memoized_method def _subsystem_instances(self): diff --git a/src/python/pants/backend/native/subsystems/platform_specific/linux/glibc.py b/src/python/pants/backend/native/subsystems/platform_specific/linux/glibc.py deleted file mode 100644 index c2523f091fd2..000000000000 --- a/src/python/pants/backend/native/subsystems/platform_specific/linux/glibc.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). -# Licensed under the Apache License, Version 2.0 (see LICENSE). - -from __future__ import (absolute_import, division, generators, nested_scopes, print_function, - unicode_literals, with_statement) - -import os - -from pants.binaries.binary_tool import NativeTool - - -class GLibc(NativeTool): - options_scope = 'glibc' - default_version = '2.23' - archive_type = 'tgz' - - def lib_dir(self): - return os.path.join(self.select(), 'lib') diff --git a/src/python/pants/backend/python/tasks/setup_py.py b/src/python/pants/backend/python/tasks/setup_py.py index 2c2422e1289c..fa06e125099b 100644 --- a/src/python/pants/backend/python/tasks/setup_py.py +++ b/src/python/pants/backend/python/tasks/setup_py.py @@ -79,7 +79,7 @@ def _setup_command(self): return self.__setup_command -class SetupPyInvocationEnvironment(datatype(['joined_path', 'glibc_dir'])): +class SetupPyInvocationEnvironment(datatype(['joined_path'])): def as_env_dict(self): ret = { @@ -88,9 +88,6 @@ def as_env_dict(self): 'PATH': self.joined_path, } - if self.glibc_dir: - ret['LD_LIBRARY_PATH'] = self.glibc_dir - return ret @@ -98,8 +95,7 @@ def as_env_dict(self): def get_setup_py_env(native_toolchain): # Isolate the PATH to just our toolchain. joined_path = get_joined_path(native_toolchain.path_entries()) - # Include the glibc lib directory for crti.o. - return SetupPyInvocationEnvironment(joined_path, native_toolchain.glibc_dir()) + return SetupPyInvocationEnvironment(joined_path) class TargetAncestorIterator(object): diff --git a/tests/python/pants_test/backend/native/subsystems/BUILD b/tests/python/pants_test/backend/native/subsystems/BUILD index e87e712b8cac..6ec33f4ba008 100644 --- a/tests/python/pants_test/backend/native/subsystems/BUILD +++ b/tests/python/pants_test/backend/native/subsystems/BUILD @@ -10,4 +10,5 @@ python_tests( 'tests/python/pants_test:base_test', 'tests/python/pants_test/subsystem:subsystem_utils', ], + tags={'platform_specific_behavior'}, ) diff --git a/tests/python/pants_test/backend/native/subsystems/test_native_toolchain.py b/tests/python/pants_test/backend/native/subsystems/test_native_toolchain.py index 26be9f12ff67..d7343b1b8bb0 100644 --- a/tests/python/pants_test/backend/native/subsystems/test_native_toolchain.py +++ b/tests/python/pants_test/backend/native/subsystems/test_native_toolchain.py @@ -5,6 +5,8 @@ from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) +import os + from pants.backend.native.subsystems.native_toolchain import NativeToolchain from pants.util.contextutil import environment_as, get_joined_path from pants.util.process_handler import subprocess @@ -23,17 +25,15 @@ def setUp(self): super(TestNativeToolchain, self).setUp() self.toolchain = global_subsystem_instance(NativeToolchain) + def _get_test_file_path(self, path): + return os.path.join(self.build_root, path) + def _invoke_capturing_output(self, cmd, cwd=None): if cwd is None: cwd = self.build_root toolchain_dirs = self.toolchain.path_entries() - isolated_toolchain_path = get_joined_path(toolchain_dirs) - process_invocation_env = dict(PATH=isolated_toolchain_path) - - glibc_dir = self.toolchain.glibc_dir() - if glibc_dir: - process_invocation_env['LD_LIBRARY_PATH'] = glibc_dir + process_invocation_env = dict(PATH=get_joined_path(toolchain_dirs)) try: with environment_as(**process_invocation_env): @@ -56,13 +56,11 @@ def test_hello_c(self): } """) - self._invoke_capturing_output(['gcc', 'hello.c', '-o', 'hello_gcc']) - gcc_output = self._invoke_capturing_output(['./hello_gcc']) - self.assertEqual(gcc_output, 'hello, world!\n') + self._invoke_capturing_output(['gcc', '-c', 'hello.c', '-o', 'hello_gcc.o']) + self.assertTrue(os.path.isfile(self._get_test_file_path('hello_gcc.o'))) - self._invoke_capturing_output(['clang', 'hello.c', '-o', 'hello_clang']) - clang_output = self._invoke_capturing_output(['./hello_clang']) - self.assertEqual(clang_output, 'hello, world!\n') + self._invoke_capturing_output(['clang', '-c', 'hello.c', '-o', 'hello_clang.o']) + self.assertTrue(os.path.isfile(self._get_test_file_path('hello_clang.o'))) def test_hello_cpp(self): self.create_file('hello.cpp', contents=""" @@ -73,10 +71,8 @@ def test_hello_cpp(self): } """) - self._invoke_capturing_output(['g++', 'hello.cpp', '-o', 'hello_g++']) - gpp_output = self._invoke_capturing_output(['./hello_g++']) - self.assertEqual(gpp_output, 'hello, world!\n') + self._invoke_capturing_output(['g++', '-c', 'hello.cpp', '-o', 'hello_g++.o']) + self.assertTrue(os.path.isfile(self._get_test_file_path('hello_g++.o'))) - self._invoke_capturing_output(['clang++', 'hello.cpp', '-o', 'hello_clang++']) - clangpp_output = self._invoke_capturing_output(['./hello_clang++']) - self.assertEqual(clangpp_output, 'hello, world!\n') + self._invoke_capturing_output(['clang++', '-c', 'hello.cpp', '-o', 'hello_clang++.o']) + self.assertTrue(os.path.isfile(self._get_test_file_path('hello_clang++.o')))