AcademySoftwareFoundation / AcademySoftwareFoundation/OpenShadingLanguage
Race condition when building testshade_llvm_compiled_rs
- Dominant language
- C++
- Stars
- 2.3k
- Forks
- 414
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 10
Description
In a parallel build, `testshade_llvm_compiled_rs.bc` and `testshade_llvm_compiled_rs.bc.cpp` are generated two to three times.
The next command can use the truncated result, which is being overwritten by the second or third generation.
This is an example from the build log:
```
[ 86%] Generating testshade_llvm_compiled_rs.bc
cd /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade && /usr/lib/llvm-15.0/bin/llvm-link -internalize /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/rs_simplerend_host.bc -o /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/testshade_llvm_compiled_rs.bc
[ 86%] Generating testshade_llvm_compiled_rs.bc.cpp
cd /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/src/testshade && /usr/bin/python3.11 /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/src/build-scripts/serialize-bc.py /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/testshade_llvm_compiled_rs.bc /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/testshade_llvm_compiled_rs.bc.cpp testshade_llvm_compiled_rs
[ 87%] Generating testshade_llvm_compiled_rs.bc
cd /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade && /usr/lib/llvm-15.0/bin/llvm-link -internalize /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/rs_simplerend_host.bc -o /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/testshade_llvm_compiled_rs.bc
[ 90%] Generating testshade_llvm_compiled_rs.bc.cpp
cd /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/src/testshade && /usr/bin/python3.11 /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/src/build-scripts/serialize-bc.py /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/testshade_llvm_compiled_rs.bc /usr/src/RPM/BUILD/openshadinglanguage-1.12.14.0/x86_64-alt-linux/src/testshade/testshade_llvm_compiled_rs.bc.cpp testshade_llvm_compiled_rs
```
### Versions
* OSL branch/version: 1.12.8.0, 1.12.13.0, 1.12.14.0
* OS: ALT Linux
* C++ compiler: doesn't matter
* LLVM version: doesn't matter
* OIIO version: doesn't matter
Contributor guide
Research direction
Inspect the build rules that generate testshade_llvm_compiled_rs.bc and testshade_llvm_compiled_rs.bc.cpp, including build-scripts/serialize-bc.py and the rs_simplerend_host.bc input. Reproduce the issue with a parallel build and trace the dependency ordering. Done means both generated outputs are produced once from a complete input and parallel builds no longer consume truncated results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100