Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dkurt
Copy link
Member

@dkurt dkurt commented Sep 21, 2022

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

from https://github.com/riscv-collab/riscv-gnu-toolchain, default install path is /opt/riscv and they recommend add it to the PATH variable.

@asmorkalov
Copy link
Contributor

/cc @hanliutong

@asmorkalov asmorkalov self-requested a review September 21, 2022 13:07
@asmorkalov asmorkalov self-assigned this Sep 21, 2022
@asmorkalov asmorkalov merged commit 71ae1ca into opencv:4.x Sep 21, 2022
@dkurt dkurt deleted the riscv_toolchain branch September 21, 2022 13:20
@Incarnation-p-lee
Copy link

As I understand, if I pass -DCMAKE_C_COMPILER=xxx and -DCMAKE_CXX_COMPILER from the cmake cmd line, it should work well as expected, right? For example as below.

cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/riscv64-gcc.toolchain.cmake \
  -DCMAKE_C_COMPILER=/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-gcc \
  -DCMAKE_CXX_COMPILER=/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-g++ \
  ../

@dkurt
Copy link
Member Author

dkurt commented Nov 9, 2022

@Incarnation-p-lee, yes, that should work.

@Incarnation-p-lee
Copy link

Looks the variables were unset by accident, see the below logs. Finally, it will have errors like

CMake Error at /home/pli/repos/riscv/libraries/opencv/platforms/linux/riscv64-gcc.toolchain.cmake:18 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  /home/pli/repos/riscv/libraries/opencv/__BUILD/CMakeFiles/3.22.1/CMakeSystem.cmake:6 (include)
  /home/pli/repos/riscv/libraries/opencv/__BUILD/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)
>> cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/riscv64-gcc.toolchain.cmake -DCMAKE_C_COMPILER=/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-gcc -DCMAKE_CXX_COMPILER=/home/pli/bin/gnu-rv64-linux/bin/[28/11710]
known-linux-gnu-g++ ../ --debug-output
Running with debug output on.
/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-gcc
   Called from: [3]     /home/pli/repos/riscv/libraries/opencv/platforms/linux/riscv64-gcc.toolchain.cmake
                [2]     /home/pli/repos/riscv/libraries/opencv/__BUILD/CMakeFiles/3.22.1/CMakeSystem.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-g++
   Called from: [3]     /home/pli/repos/riscv/libraries/opencv/platforms/linux/riscv64-gcc.toolchain.cmake
                [2]     /home/pli/repos/riscv/libraries/opencv/__BUILD/CMakeFiles/3.22.1/CMakeSystem.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake:143 (set):
  Policy CMP0126 is not set: set(CACHE) does not remove a normal variable of
  the same name.  Run "cmake --help-policy CMP0126" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  For compatibility with older versions of CMake, normal variable
  "CMAKE_CXX_COMPILER" will be removed from the current scope.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake:66 (_cmake_find_compiler_path)
  CMakeLists.txt:113 (enable_language)
This warning is for project developers.  Use -Wno-dev to suppress it.

   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake                                                                                                                                                               [2]     /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt                                                                                                                                                    -- The CXX compiler identification is GNU 12.2.0
   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeDetermineCompilerId.cmake                                                                                                                                                             [2]     /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake:143 (set):
  Policy CMP0126 is not set: set(CACHE) does not remove a normal variable of
  the same name.  Run "cmake --help-policy CMP0126" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  For compatibility with older versions of CMake, normal variable
  "CMAKE_C_COMPILER" will be removed from the current scope.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake:68 (_cmake_find_compiler_path)
  CMakeLists.txt:113 (enable_language)
This warning is for project developers.  Use -Wno-dev to suppress it.

   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake
                [2]     /usr/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
-- The C compiler identification is GNU 12.2.0
   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeDetermineCompilerId.cmake
                [2]     /usr/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
-- Check for working CXX compiler: /home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-g++
   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeTestCompilerCommon.cmake
                [2]     /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
CMAKE_C_COMPILER-NOTFOUND
   Called from: [2]     /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
CMAKE_CXX_COMPILER-NOTFOUND

@dkurt
Copy link
Member Author

dkurt commented Nov 9, 2022

@Incarnation-p-lee, can you please try with -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/riscv64-gnu.toolchain.cmake?

@Incarnation-p-lee
Copy link

@dkurt Sure, but almost the same.

>> cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/riscv64-gnu.toolchain.cmake -DCMAKE_C_COMPILER=/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-gcc -DCMAKE_CXX_COMPILER=/home/pli/bin/gnu-rv64-linux/bin/riscv64-un
known-linux-gnu-g++ ../ --debug-output
Running with debug output on.
/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-gcc
   Called from: [3]     /home/pli/repos/riscv/libraries/opencv/platforms/linux/riscv64-gcc.toolchain.cmake
                [2]     /home/pli/repos/riscv/libraries/opencv/__BUILD/CMakeFiles/3.22.1/CMakeSystem.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
/home/pli/bin/gnu-rv64-linux/bin/riscv64-unknown-linux-gnu-g++
   Called from: [3]     /home/pli/repos/riscv/libraries/opencv/platforms/linux/riscv64-gcc.toolchain.cmake
                [2]     /home/pli/repos/riscv/libraries/opencv/__BUILD/CMakeFiles/3.22.1/CMakeSystem.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake:143 (set):
  Policy CMP0126 is not set: set(CACHE) does not remove a normal variable of
  the same name.  Run "cmake --help-policy CMP0126" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  For compatibility with older versions of CMake, normal variable
  "CMAKE_CXX_COMPILER" will be removed from the current scope.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake:66 (_cmake_find_compiler_path)
  CMakeLists.txt:113 (enable_language)
This warning is for project developers.  Use -Wno-dev to suppress it.

   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake                                                                                                                                                               [2]     /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
-- The CXX compiler identification is GNU 12.2.0
   Called from: [3]     /usr/share/cmake-3.22/Modules/CMakeDetermineCompilerId.cmake
                [2]     /usr/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake
                [1]     /home/pli/repos/riscv/libraries/opencv/CMakeLists.txt
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake:143 (set):
  Policy CMP0126 is not set: set(CACHE) does not remove a normal variable of
  the same name.  Run "cmake --help-policy CMP0126" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  For compatibility with older versions of CMake, normal variable
  "CMAKE_C_COMPILER" will be removed from the current scope.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake:68 (_cmake_find_compiler_path)
  CMakeLists.txt:113 (enable_language)
This warning is for project developers.  Use -Wno-dev to suppress it.

@alalek
Copy link
Member

alalek commented Nov 9, 2022

platforms/linux/riscv64-gcc.toolchain.cmake:18 (get_filename_component):
get_filename_component called with incorrect number of arguments

There is no line 18 with get_filename_component() in this file.

So,

  • remove custom patches or provide them if you want help
  • always clean your build directory if you modify configuration

The last message doesn't contain any error message. See item 2


Can't reproduce:

cmake -GNinja ${OPENCV_SRC_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${OPENCV_SRC_DIR}/platforms/linux/riscv64-gcc.toolchain.cmake -DCMAKE_C_COMPILER=/home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-gcc -DCMAKE_CXX_COMPILER=/home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-g++ -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_DEBUG_INFO=ON -DCPU_BASELINE=
-- The CXX compiler identification is GNU 12.1.1
-- The C compiler identification is GNU 12.1.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
...

(riscv64-gcc.toolchain.cmake is patched: -march=rv64gcv_zfh replaced to -march=rv64gc to drop RVV 1.0 requirement)

@Incarnation-p-lee
Copy link

platforms/linux/riscv64-gcc.toolchain.cmake:18 (get_filename_component):
get_filename_component called with incorrect number of arguments

There is no line 18 with get_filename_component() in this file.

So,

  • remove custom patches or provide them if you want help
  • always clean your build directory if you modify configuration

The last message doesn't contain any error message. See item 2

Can't reproduce:

cmake -GNinja ${OPENCV_SRC_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${OPENCV_SRC_DIR}/platforms/linux/riscv64-gcc.toolchain.cmake -DCMAKE_C_COMPILER=/home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-gcc -DCMAKE_CXX_COMPILER=/home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-g++ -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_DEBUG_INFO=ON -DCPU_BASELINE=
-- The CXX compiler identification is GNU 12.1.1
-- The C compiler identification is GNU 12.1.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/alalek/projects/riscv/sc-ide/riscv-gcc/bin/riscv64-unknown-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
...

(riscv64-gcc.toolchain.cmake is patched: -march=rv64gcv_zfh replaced to -march=rv64gc to drop RVV 1.0 requirement)

Just add some message to that file which results in the line number change. It works well when given -GNinja, thank you!

@alalek alalek mentioned this pull request Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants