Address comments (except main, so far)

This commit is contained in:
Sam McCall 2020-05-07 14:05:14 +02:00
parent 3bf5d201a2
commit 73d33422ce
2 changed files with 16 additions and 10 deletions

View File

@ -19,21 +19,18 @@ args = parser.parse_args()
# Parses GLIBC_2.3 into ("GLIBC", [2,3]) # Parses GLIBC_2.3 into ("GLIBC", [2,3])
# Parses GLIBC into ("GLIBC", None) # Parses GLIBC into ("GLIBC", None)
def parse_version(version): def parse_version(version):
parts = version.split('_', 1) parts = version.rsplit('_', 1)
if len(parts) == 1: if len(parts) == 1:
return (version, None) return (version, None)
try:
return (parts[0], [int(p) for p in parts[1].split('.')]) return (parts[0], [int(p) for p in parts[1].split('.')])
except ValueError:
return (version, None)
lib_versions = dict([parse_version(v) for v in args.lib]) lib_versions = dict([parse_version(v) for v in args.lib])
# Determines whether an optionally-versioned symbol is acceptable.
def accept_symbol(sym):
if sym in args.sym:
return True
split = sym.split('@', 1)
return (split[0] in args.sym) or (len(split) == 2 and accept_lib(split[1]))
# Determines whether all symbols with version 'lib' are acceptable. # Determines whether all symbols with version 'lib' are acceptable.
# A versioned library is name_x.y.z by convention.
def accept_lib(lib): def accept_lib(lib):
(lib, ver) = parse_version(lib) (lib, ver) = parse_version(lib)
if not lib in lib_versions: # Non-whitelisted library. if not lib in lib_versions: # Non-whitelisted library.
@ -44,6 +41,14 @@ def accept_lib(lib):
return False return False
return ver <= lib_versions[lib] return ver <= lib_versions[lib]
# Determines whether an optionally-versioned symbol is acceptable.
# A versioned symbol is symbol@version as output by nm.
def accept_symbol(sym):
if sym in args.sym:
return True
split = sym.split('@', 1)
return (split[0] in args.sym) or (len(split) == 2 and accept_lib(split[1]))
# Run nm to find the undefined symbols, and check whether each is acceptable. # Run nm to find the undefined symbols, and check whether each is acceptable.
nm = subprocess.run(['nm', '-uD', '--with-symbol-version', args.binary], nm = subprocess.run(['nm', '-uD', '--with-symbol-version', args.binary],
stdout=subprocess.PIPE, text=True) stdout=subprocess.PIPE, text=True)

View File

@ -8,7 +8,8 @@ is being able to cut releases easily whenever we want.
The releases are just a zip archive containing the `clangd` binary, and the The releases are just a zip archive containing the `clangd` binary, and the
clang builtin headers. They should be runnable immediately after extracting the clang builtin headers. They should be runnable immediately after extracting the
archive. The linux binary has `libstdc++` and other dependencies statically archive. The linux binary has `libstdc++` and other dependencies statically
linked for maximum portability. linked for maximum portability, and requires glibc 2.18 (the first version with
`thread_local` support).
## Creating a release manually ## Creating a release manually