From ab5126023260fba2eaf336a7d292dae9313d70db Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Sun, 5 Nov 2023 19:14:40 -0600 Subject: Issue #2373 - Remove obsolete GLIBCXX version checks. These version checks were only used with --enable-stdcxx-compat, which as far as I can tell no UXP application has ever relied on. The only use case seems to have been building with clang against an old version of GCC's libc that predates C++11, let alone C++17. --- build/templates.mozbuild | 3 - config/config.mk | 34 ----------- python/mozbuild/mozbuild/configure/libstdcxx.py | 81 ------------------------- 3 files changed, 118 deletions(-) delete mode 100644 python/mozbuild/mozbuild/configure/libstdcxx.py diff --git a/build/templates.mozbuild b/build/templates.mozbuild index 4bf63cfc53..f059820d0d 100644 --- a/build/templates.mozbuild +++ b/build/templates.mozbuild @@ -8,9 +8,6 @@ def Binary(): '''Generic template for target binaries. Meant to be used by other templates.''' - if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']: - USE_LIBS += ['stdc++compat'] - # Ideally, we'd support not adding this to the LIB_IS_C_ONLY case, # but that variable is actually only set in db/sqlite/src, which # doesn't build a shared library on the relevant platforms anyways. diff --git a/config/config.mk b/config/config.mk index 2d1ff365b1..2029889728 100644 --- a/config/config.mk +++ b/config/config.mk @@ -526,45 +526,11 @@ EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER) endif EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB) -# $(call CHECK_SYMBOLS,lib,PREFIX,dep_name,test) -# Checks that the given `lib` doesn't contain dependency on symbols with a -# version starting with `PREFIX`_ and matching the `test`. `dep_name` is only -# used for the error message. -# `test` is an awk expression using the information in the variable `v` which -# contains a list of version items ([major, minor, ...]). -define CHECK_SYMBOLS -@$(TOOLCHAIN_PREFIX)readelf -sW $(1) | \ -awk '$$8 ~ /@$(2)_/ { \ - split($$8,a,"@"); \ - split(a[2],b,"_"); \ - split(b[2],v,"."); \ - if ($(4)) { \ - if (!found) { \ - print "TEST-UNEXPECTED-FAIL | check_stdcxx | We do not want these $(3) symbol versions to be used:" \ - } \ - print " ",$$8; \ - found=1 \ - } \ -} \ -END { \ - if (found) { \ - exit(1) \ - } \ -}' -endef - -ifneq (,$(MOZ_LIBSTDCXX_TARGET_VERSION)$(MOZ_LIBSTDCXX_HOST_VERSION)) -CHECK_STDCXX = $(call CHECK_SYMBOLS,$(1),GLIBCXX,libstdc++,v[1] > 3 || (v[1] == 3 && v[2] == 4 && v[3] > 16)) -CHECK_GLIBC = $(call CHECK_SYMBOLS,$(1),GLIBC,libc,v[1] > 2 || (v[1] == 2 && v[2] > 12)) -endif - ifeq (,$(filter $(OS_TARGET),WINNT Darwin)) CHECK_TEXTREL = @$(TOOLCHAIN_PREFIX)readelf -d $(1) | grep TEXTREL > /dev/null && echo 'TEST-UNEXPECTED-FAIL | check_textrel | We do not want text relocations in libraries and programs' || true endif define CHECK_BINARY -$(call CHECK_GLIBC,$(1)) -$(call CHECK_STDCXX,$(1)) $(call CHECK_TEXTREL,$(1)) $(call LOCAL_CHECKS,$(1)) $(call CHECK_MOZGLUE_ORDER,$(1)) diff --git a/python/mozbuild/mozbuild/configure/libstdcxx.py b/python/mozbuild/mozbuild/configure/libstdcxx.py deleted file mode 100644 index cab0ccb11d..0000000000 --- a/python/mozbuild/mozbuild/configure/libstdcxx.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - - -# This script find the version of libstdc++ and prints it as single number -# with 8 bits per element. For example, GLIBCXX_3.4.10 becomes -# 3 << 16 | 4 << 8 | 10 = 197642. This format is easy to use -# in the C preprocessor. - -# We find out both the host and target versions. Since the output -# will be used from shell, we just print the two assignments and evaluate -# them from shell. - -from __future__ import absolute_import - -import os -import subprocess -import re - -re_for_ld = re.compile('.*\((.*)\).*') - -def parse_readelf_line(x): - """Return the version from a readelf line that looks like: - 0x00ec: Rev: 1 Flags: none Index: 8 Cnt: 2 Name: GLIBCXX_3.4.6 - """ - return x.split(':')[-1].split('_')[-1].strip() - -def parse_ld_line(x): - """Parse a line from the output of ld -t. The output of gold is just - the full path, gnu ld prints "-lstdc++ (path)". - """ - t = re_for_ld.match(x) - if t: - return t.groups()[0].strip() - return x.strip() - -def split_ver(v): - """Covert the string '1.2.3' into the list [1,2,3] - """ - return [int(x) for x in v.split('.')] - -def cmp_ver(a, b): - """Compare versions in the form 'a.b.c' - """ - for (i, j) in zip(split_ver(a), split_ver(b)): - if i != j: - return i - j - return 0 - -def encode_ver(v): - """Encode the version as a single number. - """ - t = split_ver(v) - return t[0] << 16 | t[1] << 8 | t[2] - -def find_version(e): - """Given the value of environment variable CXX or HOST_CXX, find the - version of the libstdc++ it uses. - """ - args = e.split() - args += ['-shared', '-Wl,-t'] - p = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) - candidates = [x for x in p.stdout if 'libstdc++.so' in x] - if not candidates: - return '' - assert len(candidates) == 1 - libstdcxx = parse_ld_line(candidates[-1]) - - p = subprocess.Popen(['readelf', '-V', libstdcxx], stdout=subprocess.PIPE) - versions = [parse_readelf_line(x) - for x in p.stdout.readlines() if 'Name: GLIBCXX' in x] - last_version = sorted(versions, cmp = cmp_ver)[-1] - return encode_ver(last_version) - -if __name__ == '__main__': - cxx_env = os.environ['CXX'] - print 'MOZ_LIBSTDCXX_TARGET_VERSION=%s' % find_version(cxx_env) - host_cxx_env = os.environ.get('HOST_CXX', cxx_env) - print 'MOZ_LIBSTDCXX_HOST_VERSION=%s' % find_version(host_cxx_env) -- cgit v1.2.3