Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-10059

CMake wrongly detects the host compiler for the host-tools when configuring a build

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • None
    • Build System
    • None

    Description

      On my computer, I have the following compilers:

      • MSVC (installed in C:\Program Files (x86)\Microsoft Visual Studio 10.0\...)
      • MinGW (in C:\MinGW)
      • Cygwin x86 and x64 (in C:\Cygwin and C:\Cygwin64)
      • and of course, the RosBE toolkit (in C:\RosBE).

      I have all those compilers because I need them for different reasons.
      In order to reduce potential problems with ROS build configure, I removed from the system PATH environment all the instances of MinGW and Cygwin paths.

      Now the problem: when I configure a ROS build with RosBE, CMake wrongly assumes I want to use cygwin for compiling the host-tools, and furthermore uses an non-existing compiler C:\Cygwin64\bin\cc, hence the configuration step completely fails. I'm wondering whether there is a clean way to bypass that, and to use instead what I would think is the correct host compiler, i.e. RosBE's gcc (at least, or fall down to MSVC in case I'm running the configuration in a VS command line, or within RosBE configured for MSVC).

      In the meantime I elaborated a workaround that seems to work quite fine, see the patch below:

      Index: configure.cmd
      ===================================================================
      --- configure.cmd	(révision 68846)
      +++ configure.cmd	(copie de travail)
      @@ -187,7 +187,12 @@
           :: Launch new script instance for x86 host tools configuration
           start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR_HOST%
       ) else (
      -    cmake -G %CMAKE_GENERATOR% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
      +    :: Hackfix!
      +    if "%BUILD_ENVIRONMENT%" == "MinGW" (
      +        cmake -G %CMAKE_GENERATOR% -DCMAKE_CROSSCOMPILING:STRING=FALSE -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
      +    ) else (
      +        cmake -G %CMAKE_GENERATOR% -DCMAKE_CROSSCOMPILING:STRING=FALSE -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
      +    )
       )
       
       cd..
       

      EXPLANATIONS: to enforce the usage of the correct compiler for the host-tools, since on my computer the host-compiler and the cross-compiler are going to be the same, I explicitely specify the toolchain. However the toolchain file defines a CMake variable called CMAKE_SYSTEM_NAME,
      which causes CMake to internally define the CMAKE_CROSSCOMPILING variable, and the host-tools configuration would fail. So, to bypass this other problem, I also enforce setting CMAKE_CROSSCOMPILING to FALSE for the host-tools only.

      DISCLAIMER: This report is just here to think about the potential issues we can have using CMake.

      Attachments

        Activity

          People

            bug zilla Bug Zilla
            hbelusca hbelusca
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: