Skip to content

Commit

Permalink
Allows to skip pre-compiling VC4CL stdlib at compile time
Browse files Browse the repository at this point in the history
This is e.g. useful for packaging builds, where the pre-compilation
should happen at install time.

See #145
  • Loading branch information
doe300 committed Jul 4, 2020
1 parent 8be5d3a commit 1bb1b55
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- run:
name: configure
# Use the libLLVM of the default LLVM/CLang, disable search for SPIRV-LLVM
command: mkdir build && cd build && sudo cmake ../ -DBUILD_NUMBER=$CIRCLE_BUILD_NUM -DCROSS_COMPILE=ON -DBUILD_TESTING=ON -DLLVMLIB_FRONTEND=ON -DSPIRV_FRONTEND=OFF -DSPIRV_COMPILER_ROOT=/tmp/skip-searching -DSYSROOT_CROSS=/home/idein/cross -DCROSS_COMPILER_PATH=${HOME}/x-tools/armv6-rpi-linux-gnueabihf/bin -DCROSS_COMPILER_PREFIX="armv6-rpi-linux-gnueabihf-"
command: mkdir build && cd build && sudo cmake ../ -DBUILD_NUMBER=$CIRCLE_BUILD_NUM -DCROSS_COMPILE=ON -DBUILD_TESTING=ON -DLLVMLIB_FRONTEND=ON -DSPIRV_FRONTEND=OFF -DSPIRV_COMPILER_ROOT=/tmp/skip-searching -DVC4CL_STDLIB_PRECOMPILE=OFF -DSYSROOT_CROSS=/home/idein/cross -DCROSS_COMPILER_PATH=${HOME}/x-tools/armv6-rpi-linux-gnueabihf/bin -DCROSS_COMPILER_PREFIX="armv6-rpi-linux-gnueabihf-"
- run:
name: make
# TODO CicleCI runs out of memory
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ option(ENABLE_COVERAGE "Enables collection of code coverage via gcov" OFF)
option(CLANG_LIBRARY "Uses the libclang library for compilation, uses the clang executable otherwise" OFF)
# Option whether to enable more compile-time checks
option(ADVANCED_CHECKS "Enable advanced compile-time checks" OFF)
# Option to skipping pre-compiling the VC4CLStdLib standard-library headers at compile time. NOTE: The headers still need to be pre-compiled before execution!
option(VC4CL_STDLIB_PRECOMPILE "Enable pre-compiling of the VC4CLStdLib headers at compile time" ON)

# Path to the VC4CL standard library
# NOTE: Resolving ~ (for home directory) is currently not supported
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ add_dependencies(${VC4C_LIBRARY_NAME} variant-dependencies)
target_include_directories(${VC4C_LIBRARY_NAME} SYSTEM PRIVATE ${variant_HEADERS})
target_include_directories(${VC4C_PROGRAM_NAME} SYSTEM PRIVATE ${variant_HEADERS})

if(VC4CL_STDLIB_DIR)
if(VC4CL_STDLIB_PRECOMPILE AND VC4CL_STDLIB_DIR)
# Pre-compile VC4CL standard library files if development headers available and output files do not yet exist
add_custom_command(TARGET ${VC4C_PROGRAM_NAME} POST_BUILD
COMMAND if \[ ! -e ${VC4CL_STDLIB_DIR}/VC4CLStdLib.bc -o ! -e ${VC4CL_STDLIB_DIR}/VC4CLStdLib.h.pch \]; then $<TARGET_FILE:${VC4C_PROGRAM_NAME}> --quiet --precompile-stdlib -o ${VC4CL_STDLIB_DIR}/ ${VC4CL_STDLIB_DIR}/VC4CLStdLib.h && echo \"VC4CL standard library precompiled into ${VC4CL_STDLIB_DIR}\" \; fi
)
endif(VC4CL_STDLIB_DIR)
endif(VC4CL_STDLIB_PRECOMPILE AND VC4CL_STDLIB_DIR)

# "For shared libraries VERSION and SOVERSION can be used to specify the build version and API version respectively."
set_target_properties(
Expand Down

2 comments on commit 1bb1b55

@bronze51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "VC4CL_STDLIB_PRECOMPILE" is absent or set to ON, the file "VC4CLStdLib.h.pch" is created in "VC4CL_STDLIB_DIR".
If "VC4CL_STDLIB_DIR" is set to "/usr/local/include/vc4cl-stdlib", the file cannot be created due to a permission issue:

[E] Wed Jul 15 20:56:07 2020: Errors in precompilation:
[E] Wed Jul 15 20:56:07 2020: error: unable to open output file '/usr/local/include/vc4cl-stdlib//VC4CLStdLib.h.pch': 'Permission denied'
1 error generated.

The problem seems be caused by packaging and installing vc4cl-stdlib first, prior to building and packaging vc4c. When building and packaging vc4c one cannot rely the interim build results for vc4cl-stdlib being available.

Rather than setting VC4CL_STDLIB_PRECOMPILE to OFF, can "VC4CLStdLib.h.pch" be temporary stored somewhere else, relative to vc4c?

@doe300
Copy link
Owner Author

@doe300 doe300 commented on 1bb1b55 Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VC4CLStdLib.h.pch will be stored where VC4C expects it to be for the development build, otherwise you would not be able to run the development build directly.

In the CI to build the debian packages, the same job to build the VC4C package also builds the VC4CLStdLib package, making the VC4CLStdLib sources available locally and also allowing the VC4CLStdLib.h.pch to be build into the local directories while still having the installed VC4CLStdLib.h.pch built into /usr/local/include/vc4cl-stdlib. Can't you do the same?

If you have a build of VC4C without any VC4CLStdLib sources (or the sources already installed e.g. in /usr/local/include/vc4cl-stdlib), how should the VC4C determine some local path where the VC4CLStdLib.h.pch is pre-built into?

Please sign in to comment.