Skip to content

Fix issue #159: Failure when cross-compiling for VxWorks#160

Closed
moberhuber wants to merge 4 commits into
python-cmake-buildsystem:masterfrom
wind-river-cdt:master
Closed

Fix issue #159: Failure when cross-compiling for VxWorks#160
moberhuber wants to merge 4 commits into
python-cmake-buildsystem:masterfrom
wind-river-cdt:master

Conversation

@moberhuber

Copy link
Copy Markdown
Contributor

When cross-compiling, the cmake/extensions/CMakeLists.txt may be loaded without ${MSVC_VERSION} set. Protect against errors by making the code conditional.

Comment thread cmake/extensions/CMakeLists.txt Outdated
@@ -1,3 +1,4 @@
if(${MSVC_VERSION})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per CMake style, we can use if(MSVC_VERSION) here.

Comment thread cmake/extensions/CMakeLists.txt Outdated
@@ -21,6 +22,7 @@ if(CMAKE_VERSION VERSION_LESS 2.8.12)
set(ENABLE_CTYPES_TEST OFF CACHE BOOL "${warn}" FORCE)
endif()
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please indent the code with two spaces contained in the conditional.

@thewtex thewtex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Please see a few minor inline comments.

@moberhuber

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, I've cleaned up as requested (wanted a minimal source diff initially).
Please review again, thanks !

@thewtex

thewtex commented Oct 21, 2016

Copy link
Copy Markdown
Contributor

@moberhuber Thanks for the update! 👍

@jcfr This LGTM.

@moberhuber

Copy link
Copy Markdown
Contributor Author

I've added 2 more fixes for cross-compiling VxWorks, could these be considered please? - Thx :)

@thewtex

thewtex commented Oct 29, 2016

Copy link
Copy Markdown
Contributor

@moberhuber thanks!

LGTM

CC @jcfr

@jcfr

jcfr commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

@moberhuber Thanks again for your patches

Fixes related to libutil have been pushed into their own PR. See #165

@jcfr

jcfr commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

Fix related to sys/select.h has been pushed into its own PR. See #166

@jcfr

jcfr commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

Now for de1ffdf and fdd2c56, the exclusion of MSVC is already done when the version is empty or doesn't match, the issue happen because CMAKE_SIZEOF_VOID_P is not set.

With a working toolchain, I would expect this variable to be set to either 4 (32-bit) or 8 (64-bit), I suspect something is missing from the toolchain and/or companion files.

For reference this variable is set within CMake here using the content of the variable CMAKE_C_SIZEOF_DATA_PTR originally set here: https://github.com/Kitware/CMake/blob/60d80bca4afcfb3a38b588a5a2060cc275b4afbc/Modules/CMakeDetermineCompilerABI.cmake#L41-L59

Looking at the CMakeOutput.log should help understand better.

@moberhuber Let us know what you find out.

@moberhuber

Copy link
Copy Markdown
Contributor Author

Hi @jcfr , regarding fdd2c56 I can confirm that the issue does not occur with the GNU toolchain which does set CMAKE_SIZEOF_VOID_P as part of its compiler detection.

But for VxWorks, we also want to build with the Diab toolchain which isn't supported by stock CMake so far. So we use our own (very basic) cross-toolchain information. This works fine everywhere else, in my fork I could build a basic Python that works even without CMAKE_SIZEOF_VOID_P being set (I suspect because any important compiler / platform information is discovered directly through other mechansims).

@jcfr

jcfr commented Nov 21, 2016

Copy link
Copy Markdown
Contributor

May be you could add the following to the toolchain file:

set(CMAKE_SIZEOF_VOID_P 8)

Or we could add a statement like this in the python cmake build system:

if(NOT DEFINED CMAKE_SIZEOF_VOID_P AND CMAKE_CROSSCOMPILING)
  set(CMAKE_SIZEOF_VOID_P 8)
  message(STATUS "Defaulting CMAKE_SIZEOF_VOID_P to 8 because CMakeDetermineCompilerABI failed to do so")
endif()

Let me know what you think.

Jc

@jcfr jcfr added the Type: Bug Something's not working correctly. label Feb 15, 2017
@jcfr

jcfr commented Dec 27, 2021

Copy link
Copy Markdown
Contributor

To summarize:

If the last issue related to CMAKE_SIZEOF_VOID_P is still relevant, consider creating a new issue and evaluating the approach proposed in #160 (comment)

@jcfr jcfr closed this Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something's not working correctly.

Development

Successfully merging this pull request may close these issues.

3 participants