Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patch on llvm 19.1.6 to take care of temporary files generated at runtime #1476

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions recipes/recipes_emscripten/llvm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
# clear LDFLAGS flags because they contain sWASM_BIGINT
export LDFLAGS=""


# Configure step
cmake ${CMAKE_ARGS} -S ../llvm -B . \
emcmake cmake ${CMAKE_ARGS} -S ../llvm -B . \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \
-DLLVM_TARGETS_TO_BUILD="WebAssembly" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DLLVM_ENABLE_THREADS=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
Expand All @@ -30,10 +29,10 @@ cmake ${CMAKE_ARGS} -S ../llvm -B . \
-DCMAKE_CXX_FLAGS="-Dwait4=__syscall_wait4"

# Build step
make -j4
emmake make -j4

# Install step
make install
emmake make install

# Copy all files with ".wasm" extension to $PREFIX/bin
cp $SRC_DIR/build/bin/*.wasm $PREFIX/bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index aa10b160ccf8..184867e2b55f 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -76,8 +76,8 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
- std::string ObjectFileName = PTU.TheModule->getName().str() + ".o";
- std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm";
+ std::string ObjectFileName = "/tmp/" + PTU.TheModule->getName().str() + ".o";
+ std::string BinaryFileName = "/tmp/" + PTU.TheModule->getName().str() + ".wasm";

std::error_code Error;
llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), Error);
3 changes: 2 additions & 1 deletion recipes/recipes_emscripten/llvm/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ source:
sha256: f07fdcbb27b2b67aa95e5ddadf45406b33228481c250e65175066d36536a1ee2
patches:
- patches/cross_compile.patch
- patches/shift_temporary_files_to_tmp_dir.patch

build:
number: 0
number: 1

requirements:
build:
Expand Down
Loading