clang-tool-chain 1.1.4__py3-none-any.whl → 1.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ from clang_tool_chain.env_utils import (
9
9
  )
10
10
  from clang_tool_chain.execution.sanitizer_env import (
11
11
  detect_sanitizers_from_flags,
12
+ get_runtime_dll_paths,
12
13
  get_symbolizer_path,
13
14
  prepare_sanitizer_environment,
14
15
  )
@@ -27,6 +28,7 @@ __all__ = [
27
28
  "CONTROLLABLE_FEATURES",
28
29
  # Sanitizer environment
29
30
  "prepare_sanitizer_environment",
31
+ "get_runtime_dll_paths",
30
32
  "get_symbolizer_path",
31
33
  "detect_sanitizers_from_flags",
32
34
  ]
@@ -1,3 +1,3 @@
1
1
  """Version information for clang-tool-chain."""
2
2
 
3
- __version__ = "1.1.4"
3
+ __version__ = "1.1.5"
@@ -12,6 +12,7 @@ from clang_tool_chain.execution.build import build_main, build_run_main
12
12
  from clang_tool_chain.execution.core import execute_tool, run_tool, sccache_clang_cpp_main, sccache_clang_main
13
13
  from clang_tool_chain.execution.sanitizer_env import (
14
14
  detect_sanitizers_from_flags,
15
+ get_runtime_dll_paths,
15
16
  get_symbolizer_path,
16
17
  prepare_sanitizer_environment,
17
18
  )
@@ -29,5 +30,6 @@ __all__ = [
29
30
  # Sanitizer utilities
30
31
  "prepare_sanitizer_environment",
31
32
  "detect_sanitizers_from_flags",
33
+ "get_runtime_dll_paths",
32
34
  "get_symbolizer_path",
33
35
  ]
@@ -1,9 +1,9 @@
1
1
  """
2
2
  Sanitizer runtime environment configuration.
3
3
 
4
- This module provides automatic injection of ASAN_OPTIONS, LSAN_OPTIONS, and
5
- ASAN_SYMBOLIZER_PATH environment variables to improve stack trace quality
6
- when running executables compiled with Address Sanitizer or Leak Sanitizer.
4
+ This module provides automatic injection of ASAN_OPTIONS, LSAN_OPTIONS,
5
+ ASAN_SYMBOLIZER_PATH, and PATH environment variables to ensure executables
6
+ compiled with Address Sanitizer or Leak Sanitizer can run correctly.
7
7
 
8
8
  The default options fix <unknown module> entries in stack traces from
9
9
  dlopen()'d shared libraries by enabling slow unwinding and symbolization.
@@ -11,6 +11,10 @@ dlopen()'d shared libraries by enabling slow unwinding and symbolization.
11
11
  The symbolizer path is automatically detected from the clang-tool-chain
12
12
  installation, enabling proper address-to-symbol resolution without manual
13
13
  configuration.
14
+
15
+ On Windows with shared ASAN runtime (-shared-libasan), the clang runtime
16
+ DLL directory is automatically added to PATH to ensure the ASAN DLL can
17
+ be found at runtime.
14
18
  """
15
19
 
16
20
  import logging
@@ -71,6 +75,62 @@ def get_symbolizer_path() -> str | None:
71
75
  return None
72
76
 
73
77
 
78
+ def get_runtime_dll_paths() -> list[str]:
79
+ """
80
+ Get paths to directories containing runtime DLLs (Windows only).
81
+
82
+ On Windows, when using shared ASAN runtime (-shared-libasan), the
83
+ libclang_rt.asan_dynamic-x86_64.dll must be findable at runtime.
84
+ This function returns the paths that should be added to PATH.
85
+
86
+ Returns:
87
+ List of directory paths containing runtime DLLs, or empty list
88
+ if not applicable (non-Windows or DLLs not found).
89
+
90
+ Example:
91
+ >>> paths = get_runtime_dll_paths()
92
+ >>> if paths:
93
+ ... os.environ["PATH"] = os.pathsep.join(paths) + os.pathsep + os.environ.get("PATH", "")
94
+ """
95
+ if platform.system() != "Windows":
96
+ return []
97
+
98
+ paths = []
99
+
100
+ try:
101
+ from clang_tool_chain.platform.detection import get_platform_binary_dir, get_platform_info
102
+
103
+ # Get platform info for sysroot lookup
104
+ _platform_name, arch = get_platform_info()
105
+
106
+ # Get the clang bin directory and sysroot bin directory
107
+ clang_bin_dir = get_platform_binary_dir()
108
+ clang_root = clang_bin_dir.parent
109
+
110
+ # Add clang bin directory (for some sanitizer DLLs)
111
+ if clang_bin_dir.exists():
112
+ paths.append(str(clang_bin_dir))
113
+
114
+ # Add MinGW sysroot bin directory (where libclang_rt.asan_dynamic-x86_64.dll lives)
115
+ if arch == "x86_64":
116
+ sysroot_name = "x86_64-w64-mingw32"
117
+ elif arch == "arm64":
118
+ sysroot_name = "aarch64-w64-mingw32"
119
+ else:
120
+ sysroot_name = None
121
+
122
+ if sysroot_name:
123
+ sysroot_bin = clang_root / sysroot_name / "bin"
124
+ if sysroot_bin.exists():
125
+ paths.append(str(sysroot_bin))
126
+ logger.debug(f"Found MinGW sysroot bin: {sysroot_bin}")
127
+
128
+ except (ImportError, RuntimeError) as e:
129
+ logger.debug(f"Could not get runtime DLL paths: {e}")
130
+
131
+ return paths
132
+
133
+
74
134
  def detect_sanitizers_from_flags(compiler_flags: list[str]) -> tuple[bool, bool]:
75
135
  """
76
136
  Detect which sanitizers are enabled from compiler flags.
@@ -224,6 +284,20 @@ def prepare_sanitizer_environment(
224
284
  "or ensure clang-tool-chain is properly installed."
225
285
  )
226
286
 
287
+ # On Windows, add runtime DLL paths to PATH for shared ASAN runtime
288
+ # This ensures libclang_rt.asan_dynamic-x86_64.dll can be found at runtime
289
+ if asan_enabled and platform.system() == "Windows":
290
+ dll_paths = get_runtime_dll_paths()
291
+ if dll_paths:
292
+ current_path = env.get("PATH", "")
293
+ # Prepend DLL paths to ensure they take priority
294
+ new_path = os.pathsep.join(dll_paths)
295
+ if current_path:
296
+ env["PATH"] = new_path + os.pathsep + current_path
297
+ else:
298
+ env["PATH"] = new_path
299
+ logger.info(f"Injecting runtime DLL paths to PATH: {dll_paths}")
300
+
227
301
  # Add platform-specific LSan suppressions if LSAN is enabled
228
302
  if lsan_enabled:
229
303
  # Check if user explicitly disabled built-in suppressions with ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clang-tool-chain
3
- Version: 1.1.4
3
+ Version: 1.1.5
4
4
  Summary: Clang Tool Chain - C/C++ compilation toolchain utilities
5
5
  Project-URL: Homepage, https://github.com/zackees/clang-tool-chain
6
6
  Project-URL: Repository, https://github.com/zackees/clang-tool-chain
@@ -1,5 +1,5 @@
1
- clang_tool_chain/__init__.py,sha256=u-qgOuQxh5W2g7n8BgUtBnUWsK66rM4N6LJXY9PiEx0,880
2
- clang_tool_chain/__version__.py,sha256=OZTe0l-1KRXG_B5GhtooBTlUxPJy68FJ5pyGG4KC95U,71
1
+ clang_tool_chain/__init__.py,sha256=nLK5yA3seauLHvtQN3Qfe8_XLfbs8b-noek_3baRRZc,936
2
+ clang_tool_chain/__version__.py,sha256=jG7OiD1U-R4k5RPrITUrVwY2AnwCm3EQkm__FP_IjMI,71
3
3
  clang_tool_chain/archive.py,sha256=t3reh7cm5XP2rhTqfRIDAQZv5XQq7SsstyiROYg8wFA,27697
4
4
  clang_tool_chain/archive_cache.py,sha256=5ZmlwXIJZDcrDFkTbdgBQYN9sulGn0WyI6qwWqC4HEU,6806
5
5
  clang_tool_chain/checksums.py,sha256=KFXeAeDz5ZlcZVOxsHDpNDCrm9UDoJ8bMA4PeNhuzdA,9868
@@ -38,7 +38,7 @@ clang_tool_chain/deployment/libdeploy.py,sha256=cfyDFmbuUmimss5fv7exO7NOulDnw7ag
38
38
  clang_tool_chain/deployment/so_deployer.py,sha256=eAygmGojioi1iz5cHeqmKjJ5fI-5XooG9Ro-5TIA0gw,12867
39
39
  clang_tool_chain/directives/__init__.py,sha256=MJDNYL_MD2MF0HFsrTsSTX645bYo6vtjq2pOTtfykaU,198
40
40
  clang_tool_chain/directives/parser.py,sha256=6J7mO1JtvuHkkKS0Xges5b_jT9b3uTF6ULI0ZiwGAdw,11179
41
- clang_tool_chain/execution/__init__.py,sha256=fFQEW9VejCdbBvt4quNJ2X8udh_PKgewTfzUXHmXzyc,940
41
+ clang_tool_chain/execution/__init__.py,sha256=-jrL19U2UkP6qcUQVNq2qB0txg2TGXXTpXn_wXjVemg,996
42
42
  clang_tool_chain/execution/arg_transformers.py,sha256=Vut8XHp4IHkEUhVRI-NSvFaX6EvrGDd3FCEHbDe9gHo,26268
43
43
  clang_tool_chain/execution/build.py,sha256=YHS1BJTZg5pBS9czVko41mBdfswSPad5hxfitMoLvsI,13275
44
44
  clang_tool_chain/execution/build_pipeline.py,sha256=ORJEJ8WYp8c7bhWAa-e3w_ySXwenpUczlmXgoGByToY,17823
@@ -49,7 +49,7 @@ clang_tool_chain/execution/iwyu.py,sha256=bmP0d_PZObA1JfmFYp3qIOKCb7y32AWPm2_ReF
49
49
  clang_tool_chain/execution/lldb.py,sha256=VpxkWTPS6PsyskaKTALeziR5Z5NLwarW174Fm1SMX9k,20718
50
50
  clang_tool_chain/execution/nodejs_resolver.py,sha256=8QsJWvIfmt5mBDV7n0ypSjsPyXS-eZTizhBli937I-g,11172
51
51
  clang_tool_chain/execution/platform_executor.py,sha256=sF4GyW0ujy2EewG8y2Eo1gUWGzss5G5iIkv02w7-2_o,14362
52
- clang_tool_chain/execution/sanitizer_env.py,sha256=bLGUATKNnuB8WxWt1eopVgEh6bsZzkmpcpGxYOeRcHk,10642
52
+ clang_tool_chain/execution/sanitizer_env.py,sha256=OE00wOEaLm-HIWL1fdjhQWEZ9D1hVN3bYfMxUEo8ZiQ,13364
53
53
  clang_tool_chain/installers/__init__.py,sha256=NAV5woPCEDKSbFr1UmfQsrg4Ua5UdghN4q7H3ymvRsg,279
54
54
  clang_tool_chain/installers/base.py,sha256=OS78bau9zoYPitmhla7pKsfCPEj-zLY0DkvVzjE31Tw,15437
55
55
  clang_tool_chain/installers/clang.py,sha256=rUtheVRF7mq_1YdmQ3XzIybrJqsHbm2Xf0cbhRbH7RQ,16994
@@ -71,8 +71,8 @@ clang_tool_chain/symbolizer/unwind_windows.h,sha256=XTWhJDv13AAMUPAzWCfRN7tO6EbN
71
71
  clang_tool_chain/testing/__init__.py,sha256=-sYqOOCuTV_u-MkmExrD4uKdTHG4RmMwR3D1kIG281Q,208
72
72
  clang_tool_chain/testing/diagnostic_runner.py,sha256=mnmFUEOQulY3-Ggu6hKVGZwjrKQNmV6kY80PRTUu2qU,5293
73
73
  clang_tool_chain/testing/diagnostic_tests.py,sha256=GmtKWrDcddZTpx9_yIKfhRAy6YOde8dj7SksCWVEME4,6019
74
- clang_tool_chain-1.1.4.dist-info/METADATA,sha256=EQviHfowQcUB26PHuj-VYtH5YfTNoE1b2D8DOXArOT8,60267
75
- clang_tool_chain-1.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
76
- clang_tool_chain-1.1.4.dist-info/entry_points.txt,sha256=N0a0OVPkCFbf6BisRkHj-m2TcZ-f1mqxfXxAHQxfrQg,2800
77
- clang_tool_chain-1.1.4.dist-info/licenses/LICENSE,sha256=51FO1oc2pZbQNI0v0_THnznnZIF4iFgawG1xnQ58kKo,10997
78
- clang_tool_chain-1.1.4.dist-info/RECORD,,
74
+ clang_tool_chain-1.1.5.dist-info/METADATA,sha256=V3_teL2iXVtyGp-CJKBjeYgC2UhYj0KlTXc2d9pWZtQ,60267
75
+ clang_tool_chain-1.1.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
76
+ clang_tool_chain-1.1.5.dist-info/entry_points.txt,sha256=N0a0OVPkCFbf6BisRkHj-m2TcZ-f1mqxfXxAHQxfrQg,2800
77
+ clang_tool_chain-1.1.5.dist-info/licenses/LICENSE,sha256=51FO1oc2pZbQNI0v0_THnznnZIF4iFgawG1xnQ58kKo,10997
78
+ clang_tool_chain-1.1.5.dist-info/RECORD,,