Skip to content

Commit 403e571

Browse files
izaitsevfbcan-gaa-hou
authored andcommitted
fix cpp builder to avoid missing-source compile error (pytorch#160354)
Summary: the condition ``` if config.is_fbcode() and (not self._aot_mode or self._use_relative_path): sources = [os.path.basename(i) for i in sources] ``` unintentionally (?) stripped paths even when use_relative_path was False (as long as aot_mode was False), breaking local tests that rely on absolute temp-file paths. Fixes internal issue: ``` FAILED (errors=1) CppCompileError: C++ compile error Command: /mnt/gvfs/third-party2/llvm-fb/0f1f083aa5508772f3db24bf4f697bc118ba0958/17/platform010/72a2ff8/bin/clang-17 czyi3nhzin5b3mc3376vmfnlbjobvjcghbvv4tatuazs3syqubay.cpp -shared -fPIC -O3 -DNDEBUG -fno-trapping-math -funsafe-math-optimizations -ffinite-math-only -fno-signed-zeros -fno-math-errno -fno-finite-math-only -fno-unsafe-math-optimizations -ffp-contract=off -Wall -std=c++17 -Wno-unused-variable -Wno-unknown-pragmas -Werror=ignored-optimization-argument -g -o /re_tmp/tmpsp58ya2h/zy/test_symbol.so Output: clang-17: error: no such file or directory: 'czyi3nhzin5b3mc3376vmfnlbjobvjcghbvv4tatuazs3syqubay.cpp' clang-17: error: no input files ``` Reviewed By: clee2000 Differential Revision: D80025417 Pull Request resolved: pytorch#160354 Approved by: https://github.com/benjaminglass1, https://github.com/clee2000
1 parent 5c5c373 commit 403e571

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torch/_inductor/cpp_builder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,8 @@ def __init__(
16311631
if isinstance(sources, str):
16321632
sources = [sources]
16331633

1634-
if config.is_fbcode() and (not self._aot_mode or self._use_relative_path):
1634+
# Use relative paths only when requested (typically for remote builds)
1635+
if config.is_fbcode() and self._use_relative_path:
16351636
# Will create another temp directory for building, so do NOT use the
16361637
# absolute path.
16371638
self._orig_source_paths = list(sources)

0 commit comments

Comments
 (0)