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

gcc missing error when cross compile foo_mem-ext [13757] #28

Closed
arkceajin opened this issue May 12, 2020 · 4 comments
Closed

gcc missing error when cross compile foo_mem-ext [13757] #28

arkceajin opened this issue May 12, 2020 · 4 comments

Comments

@arkceajin
Copy link

arkceajin commented May 12, 2020

I am trying to cross-compile the foonathan_memory_vendor but got below error:
The C compiler "/usr/bin/cc" is not able to compile a simple test program.

which means foonathan_memory_vendor is using the right toolchain, the compiler correctly set when cmake.
cmake foonathan_memory_vendor:

Running "/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/cmake -E server --pipe=/tmp/cmake-.RrsqKu/socket --experimental" in /home/user1/QBSP/foonathan_memory_vendor/build.
Starting to parse CMake project, using: "-DCMAKE_BUILD_TYPE:STRING=Debug", "-DCMAKE_CXX_COMPILER:FILEPATH=/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++", "-DCMAKE_CXX_COMPILER_TARGET :STRING=aarch64-poky-linux", "-DCMAKE_C_COMPILER:FILEPATH=/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc", "-DCMAKE_C_COMPILER_TARGET:STRING=aarch64-poky-linux", "-DCMAKE_MAKE_PROGRAM:FILEPATH=/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/make", "-DCMAKE_SYSROOT:STRING=/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/aarch64-poky-linux", "-DCMAKE_TOOLCHAIN_FILE:FILEPATH=/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake".
Running "/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/cmake -E server --pipe=/tmp/cmake-.xnDkiv/socket --experimental" in /home/user1/QBSP/foonathan_memory_vendor/build.
The C compiler identification is GNU 7.3.0
The CXX compiler identification is GNU 7.3.0
Check for working C compiler: /home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
Check for working C compiler: /home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: /home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++
Check for working CXX compiler: /home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_CXX_COMPILER_TARGET 

CMake Project was parsed successfully.

but after cmake it gives the GCC error when I cmake --build . --target install.
the error shows target foo_mem-ext didn't use the toolchain which I specified in foonathan_memory_vendor.


I find what is the problem:

${extra_cmake_args}

extra_cmake_args only pass -DCMAKE_POSITION_INDEPENDENT_CODE=ON-DCMAKE_BUILD_TYPE=Debug-DCMAKE_TOOLCHAIN_FILE=/home/user1/Qt/5.12.6/Boot2Qt/salvator-x/toolchain/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake to foonathan_memory_vendor.
so cmake_make_program, cmake_sysroot, cmake_c_compiler_target args didn't pass to foonathan_memory_vendor gives the GCC compiler error.

arkceajin added a commit to arkceajin/foonathan_memory_vendor that referenced this issue May 12, 2020
fixed cross-compile insufficient args error
arkceajin added a commit to arkceajin/foonathan_memory_vendor that referenced this issue May 12, 2020
@arkceajin
Copy link
Author

-- Build files have been written to: /home/user1/QBSP/build-foonathan_memory_vendor-Boot2Qt_5_12_6_Renesas_R_Car_M3_Salvator_XS-Release/foo_mem-ext-prefix/src/foo_mem-ext-build
[ 75%] Performing build step for 'foo_mem-ext'
Scanning dependencies of target foonathan_memory_node_size_debugger
[  4%] Building CXX object tool/CMakeFiles/foonathan_memory_node_size_debugger.dir/node_size_debugger.cpp.o
[  8%] Linking CXX executable nodesize_dbg
[  8%] Built target foonathan_memory_node_size_debugger
[ 13%] Generating container_node_sizes_impl.hpp
/bin/sh: 1: ../tool/nodesize_dbg: Exec format error
make[5]: *** [src/CMakeFiles/foonathan_memory.dir/build.make:62: src/container_node_sizes_impl.hpp] Error 2
make[4]: *** [CMakeFiles/Makefile2:85: src/CMakeFiles/foonathan_memory.dir/all] Error 2
make[3]: *** [Makefile:130: all] Error 2
make[2]: *** [CMakeFiles/foo_mem-ext.dir/build.make:112: foo_mem-ext-prefix/src/foo_mem-ext-stamp/foo_mem-ext-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/foo_mem-ext.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

how to stop nodesize_dbg execution

@MiguelCompany
Copy link
Member

You can also run nodesize_dbg on an emulator. More details here and here

@kk-12138
Copy link

I encountered the same issue
steps:
1. cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install -DBUILD_SHARED_LIBS=ON
the output seems ok:

-- The C compiler identification is GNU 6.2.0 -- The CXX compiler identification is GNU 6.2.0 -- Check for working C compiler: /opt/poky-craton2/2.2.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -- Check for working C compiler: /opt/poky-craton2/2.2.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /opt/poky-craton2/2.2.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -- Check for working CXX compiler: /opt/poky-craton2/2.2.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/eric/workspace/dds/fast_dds_source/Fast-DDS/foonathan_memory_vendor/build
2. sudo cmake --build . --target install
it changes to use gcc instead of arm-poky-linux-gnueabihf-gcc !!
`[ 12%] Creating directories for 'foo_mem-ext'
[ 25%] Performing download step (git clone) for 'foo_mem-ext'
Cloning into 'foo_mem-ext'...
Note: checking out 'c619113'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

HEAD is now at c619113 Whitespace clean up (#70)
Submodule 'cmake/comp' (https://github.com/foonathan/compatibility.git) registered for path 'cmake/comp'
Cloning into '/home/eric/workspace/dds/fast_dds_source/Fast-DDS/foonathan_memory_vendor/build/foo_mem-ext-prefix/src/foo_mem-ext/cmake/comp'...
Submodule path 'cmake/comp': checked out 'cd142129e30f5b3e6c6d96310daf94242c0b03bf'
[ 37%] No patch step for 'foo_mem-ext'
[ 50%] No update step for 'foo_mem-ext'
[ 62%] Performing configure step for 'foo_mem-ext'
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking flags for C++11
-- Checking flags for C++11 - Found: -std=c++11
-- Checking flags for C++14
-- Checking flags for C++14 - Found: -std=c++14
-- Checking flags for C++17
-- Checking flags for C++17 - Found: -std=c++17
-- Checking 13 features
`
How to cross compile correctly ?

@JLBuenoLopez JLBuenoLopez changed the title gcc missing error when cross compile foo_mem-ext gcc missing error when cross compile foo_mem-ext [13757] Feb 1, 2022
@jsan-rt
Copy link
Contributor

jsan-rt commented Mar 28, 2023

This should work properly now. Pull Request foonathan/memory#129 removed the need to build and run nodesize_dbg and instead relies on compile time checks to get the same information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants