Skip to content

Commit

Permalink
Warn if vendored Microsoft Visual C++ runtime is too old
Browse files Browse the repository at this point in the history
  • Loading branch information
adang1345 committed Aug 9, 2024
1 parent 53cc1ca commit 5b90f4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions delvewheel/_dll_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def platform_tag_to_type(cls, tag: str) -> typing.Optional['MachineType']:
# Set of regular expressions of DLLs whose names should not be mangled.
no_mangle_regexes = {}

# Regular expression that matches Microsoft Visual C++ runtime redistributable
# files
vc_redist = re.compile(r'((vcruntime\d.*)|(vccorlib\d.*)|(msvcp[\d_].*)|(msvcr(t|\d.*))|(concrt\d.*)|(mfc(m(ifc)?)?\d.*)|(vcamp\d.*)|(vcomp(\d.*|))|ucrtbase(d|_.*|))\.dll')

# ignore_names_x86 is a set containing the lowercase names of all DLLs that can
# be assumed to be present on 32-bit x86 Windows 7 SP1 or later. These are all
# the files with extension .dll or .drv found in C:\Windows\SysWOW64 on vanilla
Expand Down
9 changes: 9 additions & 0 deletions delvewheel/_dll_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import itertools
import os
import pathlib
import re
import struct
import subprocess
import sys
Expand Down Expand Up @@ -417,6 +418,14 @@ def get_all_needed(lib_path: str,
if dll_info:
stack.append(dll_info[0])
associated.update(dll_info[1])
if re.fullmatch(_dll_list.vc_redist, dll_name):
linker_version = pe.OPTIONAL_HEADER.MajorLinkerVersion, pe.OPTIONAL_HEADER.MinorLinkerVersion
with PEContext(dll_info[0], None, False, verbose) as pe2:
vc_redist_version = pe2.OPTIONAL_HEADER.MajorLinkerVersion, pe2.OPTIONAL_HEADER.MinorLinkerVersion
if linker_version > vc_redist_version:
linker_version = f'{linker_version[0]}.{linker_version[1]}'
vc_redist_version = f'{vc_redist_version[0]}.{vc_redist_version[1]}'
warnings.warn(f'{os.path.basename(lib_path)} was built with a newer Microsoft Visual C++ runtime ({linker_version}) than the discovered {os.path.basename(dll_info[0])} ({vc_redist_version}). This may cause compatibility issues.')
elif on_error == 'raise':
raise FileNotFoundError(f'Unable to find library: {dll_name}')
else:
Expand Down

0 comments on commit 5b90f4c

Please sign in to comment.