Skip to content

Commit

Permalink
Use new cross-compilation environment for armv6 (#30)
Browse files Browse the repository at this point in the history
* Add: use nomaddo/cross-rpi:0.2

* Fix: remove unneccesary status-message
  • Loading branch information
nomaddo authored and doe300 committed May 8, 2018
1 parent f931945 commit 7d5d906
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- run: .circleci/clang-format-diff.sh
build:
docker:
- image: nomaddo/cross-rpi:0.1
- image: nomaddo/cross-rpi:0.2
steps:
- checkout
- run:
Expand All @@ -25,10 +25,10 @@ jobs:
command: wget -O /tmp/vc4c.deb $(python .circleci/get_url.py "vc4c-" "/tmp/dump")
- run:
name: unpack dependencies
command: dpkg-deb -x /tmp/vc4cl-stdlib.deb / && dpkg-deb -x /tmp/vc4c.deb /
command: sudo dpkg-deb -x /tmp/vc4cl-stdlib.deb / && sudo dpkg-deb -x /tmp/vc4c.deb /
- run:
name: configure
command: cmake . -DCROSS_COMPILE=ON -DBUILD_TESTING=ON -DREGISTER_POKE_KERNELS=ON -DBCMHOST_LIBRARY=/usr/arm-linux-gnueabihf/opt/vc/lib/libbcm_host.so
command: cmake . -DCROSS_COMPILE=ON -DBUILD_TESTING=ON -DREGISTER_POKE_KERNELS=ON -DBCMHOST_LIBRARY=/opt/vc/lib/libbcm_host.so -DCROSS_COMPILER_PATH=${HOME}/x-tools/armv6-rpi-linux-gnueabihf/bin -DCROSS_COMPILER_PREFIX="armv6-rpi-linux-gnueabihf-" -DSYSROOT_CROSS=${HOME}/cross -DOpenCL_LIBRARY=${HOME}/cross/usr/lib -DOpenCL_INCLUDE_DIR="${HOME}/cross/usr/include"
- run:
name: build
command: make -j`nproc`
Expand Down
26 changes: 14 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ if(CROSS_COMPILE)
if(NOT CROSS_COMPILER_PATH)
set(CROSS_COMPILER_PATH "/usr/bin")
endif()
#Set Cross compiler
SET(CMAKE_SYSTEM_NAME "Linux")
SET(CMAKE_C_COMPILER "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-gcc")
SET(CMAKE_CXX_COMPILER "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-g++")
SET(CMAKE_FIND_ROOT_PATH "${CROSS_COMPILER_PATH}/../../")
SET(CMAKE_AR "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-ar")
SET(CMAKE_CXX_COMPILER_AR "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-gcc-ar")
SET(CMAKE_CXX_COMPILER_RANLIB "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-ranlib")
SET(CMAKE_C_COMPILER_AR "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-gcc-ar")
SET(CMAKE_CXX_COMPILER_RANLIB "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-ranlib")
SET(CMAKE_LINKER "${CROSS_COMPILER_PATH}/arm-linux-gnueabihf-ld")

if(NOT CROSS_COMPILER_PREFIX)
set(CROSS_COMPILER_PREFIX "arm-linux-gnueabihf-")
endif()

if (SYSROOT_CROSS)
# set(CMAKE_SYSROOT ${SYSROOT_CROSS})
set(CMAKE_FIND_ROOT_PATH ${SYSROOT_CROSS})
set(SYSROOT_LIBRARY_FLAGS "-Wl,-rpath-link,${SYSROOT_CROSS}/lib/arm-linux-gnueabihf:${SYSROOT_CROSS}/usr/lib/arm-linux-gnueabihf")
message(STATUS "sysroot: ${SYSROOT_CROSS}")
endif()

include(cmake/RaspberryPi.cmake)
message(STATUS "Cross compiling for Raspbian with compiler: ${CMAKE_CXX_COMPILER}")
endif()

Expand Down Expand Up @@ -185,7 +187,7 @@ endif()

if (BUILD_DEB_PACKAGE)
message(STATUS "build deb package...")

# opencl-c-headers contains the host-side OpenCL headers
set(PACKAGE_DEPENDENCIES "opencl-c-headers")
if(BUILD_ICD)
Expand Down
16 changes: 16 additions & 0 deletions cmake/RaspberryPi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Toolchain file for cross-compiling for the Raspberry Pi
SET(CMAKE_SYSTEM_NAME "Linux")

SET(CMAKE_C_COMPILER "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}gcc")
SET(CMAKE_CXX_COMPILER "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}g++")

SET(CMAKE_FIND_ROOT_PATH "${CROSS_COMPILER_PATH}/../../")

SET(CMAKE_AR "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}ar")
SET(CMAKE_CXX_COMPILER_AR "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}gcc-ar")
SET(CMAKE_CXX_COMPILER_RANLIB "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}ranlib")
SET(CMAKE_C_COMPILER_AR "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}gcc-ar")
SET(CMAKE_CXX_COMPILER_RANLIB "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}ranlib")
SET(CMAKE_LINKER "${CROSS_COMPILER_PATH}/${CROSS_COMPILER_PREFIX}ld")

set(CMAKE_CROSSCOMPILING ON)
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ file( GLOB SRCS *.cpp */*.cpp)
add_library( VC4CL SHARED ${SRCS} ${HDRS} )

if(INCLUDE_COMPILER AND EXISTS "${VC4C_HEADER_PATH}")
target_link_libraries(VC4CL ${VC4CC_LIBRARY})
target_link_libraries(VC4CL ${VC4CC_LIBRARY} ${SYSROOT_LIBRARY_FLAGS})
endif()

if(CROSS_COMPILE OR EXISTS "/opt/vc/include/bcm_host.h")
find_library(BCMHOST_LIBRARY NAMES bcm_host libbcm_host HINTS "/opt/vc/lib")
target_link_libraries(VC4CL ${BCMHOST_LIBRARY})
target_link_libraries(VC4CL ${BCMHOST_LIBRARY} ${SYSROOT_LIBRARY_FLAGS})
endif()

if(CROSS_COMPILE)
target_link_libraries(VC4CL rt)
target_link_libraries(VC4CL rt ${SYSROOT_LIBRARY_FLAGS})
endif()

# "For shared libraries VERSION and SOVERSION can be used to specify the build version and API version respectively."
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ add_dependencies(TestVC4CL cpptest-lite-project-build)
add_library(cpptest-lite SHARED IMPORTED)
ExternalProject_Get_Property(cpptest-lite-project BINARY_DIR)
set_target_properties(cpptest-lite PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/libcpptest-lite.so")
target_link_libraries(TestVC4CL cpptest-lite)
target_link_libraries(TestVC4CL VC4CL)
target_link_libraries(TestVC4CL cpptest-lite ${SYSROOT_LIBRARY_FLAGS})
target_link_libraries(TestVC4CL VC4CL ${SYSROOT_LIBRARY_FLAGS})

add_test(NAME System COMMAND ./build/test/TestVC4CL --system WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME Platform COMMAND ./build/test/TestVC4CL --platform WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
Expand All @@ -24,4 +24,4 @@ add_test(NAME Images COMMAND ./build/test/TestVC4CL --images WORKING_DIRECTORY $
add_test(NAME Programs COMMAND ./build/test/TestVC4CL --programs WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME Kernel COMMAND ./build/test/TestVC4CL --kernels WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME Events COMMAND ./build/test/TestVC4CL --events WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME Extensions COMMAND ./build/test/TestVC4CL --extensions WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME Extensions COMMAND ./build/test/TestVC4CL --extensions WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
8 changes: 4 additions & 4 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ include_directories(..)
include_directories(../include)

add_executable(v3d_info V3DInfo.cpp)
target_link_libraries(v3d_info VC4CL)
target_link_libraries(v3d_info VC4CL ${SYSROOT_LIBRARY_FLAGS})

add_executable(v3d_profile V3DProfile.cpp)
target_link_libraries(v3d_profile VC4CL)
target_link_libraries(v3d_profile VC4CL ${SYSROOT_LIBRARY_FLAGS})

add_executable(vc4cl_dump_analyzer DumpAnalyzer.cpp)
target_link_libraries(vc4cl_dump_analyzer VC4CL)
target_link_libraries(vc4cl_dump_analyzer VC4CL ${SYSROOT_LIBRARY_FLAGS})
##
# Installation targets
##
# Creates the install target for the library and the tools
install(TARGETS v3d_info EXPORT v3d_info-targets RUNTIME DESTINATION bin)
install(TARGETS v3d_profile EXPORT v3d_profile-targets RUNTIME DESTINATION bin)
install(TARGETS vc4cl_dump_analyzer EXPORT vc4cl_dump_analyzer-targets RUNTIME DESTINATION bin)
install(TARGETS vc4cl_dump_analyzer EXPORT vc4cl_dump_analyzer-targets RUNTIME DESTINATION bin)

0 comments on commit 7d5d906

Please sign in to comment.