Skip to content

Could not cross-build on Windows to armv8 due guard empty CMAKE_SYSTEM_VERSION when linking synchronization #1716

@uilianries

Description

@uilianries

Description

Greetings!

When trying to cross-build Sentry Native 0.14.0 on Windows x86_64 to ARM, the CMake setup fails with the following error:

CMake Error at CMakeLists.txt:601 (if):
  if given arguments:

    "NOT" "(" "MSVC" "AND" "CMAKE_GENERATOR_TOOLSET" "MATCHES" "_xp\$" ")" "AND" "(" "MATCHES" "^10" "OR" "MATCHES" "^6\\.[23]" ")"

  Unknown arguments specified

Full build log: https://c3i.jfrog.io/artifactory/cci-build-logs/cci/prod/PR-29690/8/package_build_logs/build_log_sentry-native_0_14_0_0882f3e8423701a51763d0f22b80e6cd_2425a446a5805f86a9ea449170118bf5910b5582.txt

The error comes from CMakeLists.txt#L601:

if(NOT (MSVC AND CMAKE_GENERATOR_TOOLSET MATCHES "_xp$")
	AND (${CMAKE_SYSTEM_VERSION} MATCHES "^10"
		OR ${CMAKE_SYSTEM_VERSION} MATCHES "^6\\.[23]"))
	list(APPEND _SENTRY_PLATFORM_LIBS "synchronization")
endif()

The CMAKE_SYSTEM_VERSION is empty when cross-building, which results in that error. A possible fix is guarding that variable, like:

        # WaitOnAddress/WakeByAddressSingle require Windows 8+
        # (Synchronization.lib). Older targets fall back to sleep-poll.
        if(NOT (MSVC AND CMAKE_GENERATOR_TOOLSET MATCHES "_xp$")
-               AND (${CMAKE_SYSTEM_VERSION} MATCHES "^10"
-                       OR ${CMAKE_SYSTEM_VERSION} MATCHES "^6\\.[23]"))
+               AND ("${CMAKE_SYSTEM_VERSION}" MATCHES "^10"
+                       OR "${CMAKE_SYSTEM_VERSION}" MATCHES "^6\\.[23]"))
                list(APPEND _SENTRY_PLATFORM_LIBS "synchronization")
        endif()
 endif()

However, it will not be enough, as synchronization will not be linked, the build will fail when linking:

CMakeFiles\sentry.dir\src\backends\sentry_backend_crashpad.cpp.obj CMakeFiles\sentry.dir\src\unwinder\sentry_unwinder_dbghelp.c.obj CMakeFiles\sentry.dir\src\screenshot\sentry_screenshot_windows.c.obj CMakeFiles\sentry.dir\Release\sentry.rc.res /out:sentry.dll /implib:sentry.lib /pdb:sentry.pdb /dll /version:0.0 /machine:ARM64 /INCREMENTAL:NO dbghelp.lib shlwapi.lib version.lib winhttp.lib crashpad_build\client\crashpad_client.lib crashpad_build\util\crashpad_util.lib crashpad_build\compat\crashpad_compat.lib crashpad_build\third_party\mpack\crashpad_mpack.lib crashpad_build\third_party\zlib\crashpad_zlib.lib user32.lib version.lib winhttp.lib crashpad_build\third_party\mini_chromium\mini_chromium.lib advapi32.lib kernel32.lib rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
   Creating library sentry.lib and object sentry.exp

sentry_batcher.c.obj : error LNK2019: unresolved external symbol WaitOnAddress referenced in function batcher_thread_func

sentry_batcher.c.obj : error LNK2019: unresolved external symbol WakeByAddressSingle referenced in function sentry__batcher_enqueue

sentry.dll : fatal error LNK1120: 2 unresolved externals

ninja: build stopped: subcommand failed.

Full build log: https://c3i.jfrog.io/artifactory/cci-build-logs/cci/prod/PR-29690/9/package_build_logs/build_log_sentry-native_0_14_0_6a875c3c2ae62f8d51a8498e55372791_2425a446a5805f86a9ea449170118bf5910b5582.txt


Still, this is a regression, because it was possible to build Sentry native 0.12.6 without errors, using the very same environment: https://c3i.jfrog.io/artifactory/cci-build-logs/cci/prod/PR-29540/4/package_build_logs/build_log_sentry-native_0_12_6_8e6f0029470062ca9dc6825291f2835f_2425a446a5805f86a9ea449170118bf5910b5582.success.txt

It may be related to a42aca5 and #880

Regards!

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: Windows 10, x86_64
  • Compiler: MSVC 19.44.35213.0
  • CMake version and config: 3.16, backend=crashpad qt=False shared=True transport=winhttp wer=False with_crashpad=sentry

Steps To Reproduce

Please, read the logs which contains the CMake commands used to configure and build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugsomething isn't working as it shouldNativeplatform label
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions