Skip to content

Commit

Permalink
Build openmp libraries for Clang/LLVM on RV64
Browse files Browse the repository at this point in the history
For Clang/LLVM, the default OpenMP library is `libomp`.

However, we don't build openmp library, which will cause a linker error:
```
riscv64-unknown-linux-gnu-ld: cannot find -lomp: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

So we build `libomp.so/libomp.a` manually.
  • Loading branch information
wangpc-pp authored and cmuellner committed Jul 19, 2024
1 parent 806c8b4 commit 5aec7d7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,47 @@ stamps/build-llvm-linux: $(LLVM_SRCDIR) $(LLVM_SRC_GIT) $(BINUTILS_SRCDIR) $(BIN
-DLLVM_PARALLEL_LINK_JOBS=4
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
# Build shared/static OpenMP libraries on RV64.
if test $(XLEN) -eq 64; then \
mkdir $(notdir $@)/openmp-shared; \
cmake -S$(LLVM_SRCDIR)/openmp \
-B$(notdir $@)/openmp-shared \
-DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \
-DCMAKE_C_COMPILER=$(INSTALL_DIR)/bin/clang \
-DCMAKE_CXX_COMPILER=$(INSTALL_DIR)/bin/clang++ \
-DOPENMP_ENABLE_LIBOMPTARGET=Off \
-DCMAKE_BUILD_TYPE=Release \
-DLIBOMP_ARCH=riscv64 \
-DLIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG=On \
-DLIBOMP_HAVE_AS_NEEDED_FLAG=On \
-DLIBOMP_HAVE_VERSION_SCRIPT_FLAG=On \
-DLIBOMP_HAVE_STATIC_LIBGCC_FLAG=On \
-DLIBOMP_HAVE_Z_NOEXECSTACK_FLAG=On \
-DDISABLE_OMPD_GDB_PLUGIN=On \
-DLIBOMP_OMPD_GDB_SUPPORT=Off \
-DLIBOMP_ENABLE_SHARED=On; \
$(MAKE) -C $(notdir $@)/openmp-shared; \
$(MAKE) -C $(notdir $@)/openmp-shared install; \
mkdir $(notdir $@)/openmp-static; \
cmake -S$(LLVM_SRCDIR)/openmp \
-B$(notdir $@)/openmp-static \
-DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \
-DCMAKE_C_COMPILER=$(INSTALL_DIR)/bin/clang \
-DCMAKE_CXX_COMPILER=$(INSTALL_DIR)/bin/clang++ \
-DOPENMP_ENABLE_LIBOMPTARGET=Off \
-DCMAKE_BUILD_TYPE=Release \
-DLIBOMP_ARCH=riscv64 \
-DLIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG=On \
-DLIBOMP_HAVE_AS_NEEDED_FLAG=On \
-DLIBOMP_HAVE_VERSION_SCRIPT_FLAG=On \
-DLIBOMP_HAVE_STATIC_LIBGCC_FLAG=On \
-DLIBOMP_HAVE_Z_NOEXECSTACK_FLAG=On \
-DDISABLE_OMPD_GDB_PLUGIN=On \
-DLIBOMP_OMPD_GDB_SUPPORT=Off \
-DLIBOMP_ENABLE_SHARED=Off; \
$(MAKE) -C $(notdir $@)/openmp-static; \
$(MAKE) -C $(notdir $@)/openmp-static install; \
fi
cp $(notdir $@)/lib/riscv$(XLEN)-unknown-linux-gnu/libc++* $(SYSROOT)/lib
cp $(notdir $@)/lib/LLVMgold.so $(INSTALL_DIR)/lib
cd $(INSTALL_DIR)/bin && ln -s -f clang $(LINUX_TUPLE)-clang && ln -s -f clang++ $(LINUX_TUPLE)-clang++
Expand Down

0 comments on commit 5aec7d7

Please sign in to comment.