Skip to content

[pthreads] support ARM arch and UWP platform#16348

Merged
vicroms merged 9 commits intomicrosoft:masterfrom
luncliff:port/pthreads
Apr 7, 2021
Merged

[pthreads] support ARM arch and UWP platform#16348
vicroms merged 9 commits intomicrosoft:masterfrom
luncliff:port/pthreads

Conversation

@luncliff
Copy link
Copy Markdown
Contributor

@luncliff luncliff commented Feb 21, 2021

What does your PR fix?

  • Check TRIPLET_SYSTEM_ARCH contains arm.
    If so, replace macro function PTW32_PROGCTR to __PTW32_PROGCTR so the build step can advance from preprocessing.

  • If VCPKG_TARGET_IS_UWP, place #pragma to link with kernel32.lib and windowsapp.lib.
    Also, inject linker option /APPCONTAINER with LINK environment variable.

  • Migrate CONTROL to vcpkg.json

Which triplets are supported/not supported? Have you updated the CI baseline?

All arm triplets for Windows (including uwp) should become available.

  • arm64-windows
  • arm-windows
  • arm64-uwp
  • x64-uwp

Does your PR follow the maintainer guide?

Wish the change followed the guide well.

I used vcpkg_replace_string instead of adding a new .patch since the source code change is trivial (3 lines in total).
Any suggestions will be welcomed :)

* arm: enable macro __PTW32_PROGCTR
* uwp: LINK option /APPCONTAINER
* uwp: link with 'kernel32', 'windowsapp'
@JackBoosY JackBoosY added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Feb 22, 2021
@JackBoosY JackBoosY requested a review from strega-nil February 22, 2021 05:48
@JackBoosY
Copy link
Copy Markdown
Contributor

cc @strega-nil for review this PR again.

poppler regression is not related to this PR.

@JackBoosY JackBoosY added info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. requires:discussion labels Feb 22, 2021
@JackBoosY
Copy link
Copy Markdown
Contributor

Poppler regression is fixing in #16356.

@strega-nil
Copy link
Copy Markdown
Contributor

@luncliff please use patches instead of this; it'll be much clearer to future maintainers. if you need any help setting that up, please ask :) (and the way you'd do that is via set(extra_patches blah.patch bloop.patch), and then passing ${extra_patches} to PATCHES)

@JackBoosY JackBoosY added requires:author-response and removed info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. requires:discussion labels Feb 23, 2021
@luncliff
Copy link
Copy Markdown
Contributor Author

luncliff commented Feb 26, 2021

So I just extracted code changes to a single patch (fix-arm-uwp.patch), but seems like the macro __cplusplus_winrt is not provided while NMAKE is running.

I think explicitly specifying kernel32 won't matter. But WindowsApp is for UWP only.
In this case, should I use vcpkg_apply_patches?

# portfile.cmake
if(VCPKG_TARGET_IS_UWP)
  vcpkg_apply_patches(SOURCE_PATH ${SOURCE_PATH} PATCHES add-uwp-pragma.patch)
  # https://docs.microsoft.com/en-us/cpp/build/reference/linker-options
  # https://docs.microsoft.com/en-us/cpp/build/reference/linking#link-environment-variables
  set(ENV{LINK} "/APPCONTAINER")
endif()
# ...

@luncliff
Copy link
Copy Markdown
Contributor Author

luncliff commented Feb 26, 2021

For future visitors who are using NMAKE, nmake-build-arm-uwp-release-out.log from 7390ef3 was like the following.

You can find well known Win32 API functions are there. And be aware of the RoInitialize with the name of __scrt_initialize_winrt. This is why I added WindowsApp.lib

	cl /errorReport:none /nologo /MD /I. /DHAVE_CONFIG_H /W3 /O2 /Ob2  /D__PTW32_BUILD_INLINED /D__PTW32_CLEANUP_C -c pthread.c
pthread.c
	rc /d__PTW32_ARCHAMD64 /d__PTW32_RC_MSC /d__PTW32_CLEANUP_C version.rc
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Copyright (C) Microsoft Corporation.  All rights reserved.


	cl /errorReport:none /nologo /LDd /Zi pthread.obj version.res /link /implib:pthreadVC3.lib  /out:pthreadVC3.dll
   Creating library pthreadVC3.lib and object pthreadVC3.exp
pthread.obj : error LNK2019: unresolved external symbol __imp_CloseHandle referenced in function __ptw32_callUserDestroyRoutines
pthread.obj : error LNK2019: unresolved external symbol __imp_DuplicateHandle referenced in function pthread_self
pthread.obj : error LNK2019: unresolved external symbol __imp_RaiseException referenced in function SetThreadName
MSVCRT.lib(helpexcept.obj) : error LNK2001: unresolved external symbol __imp_RaiseException
pthread.obj : error LNK2019: unresolved external symbol __imp_GetLastError referenced in function __ptw32_pop_cleanup
pthread.obj : error LNK2019: unresolved external symbol __imp_SetLastError referenced in function __ptw32_pop_cleanup
pthread.obj : error LNK2019: unresolved external symbol __imp_SetEvent referenced in function __ptw32_callUserDestroyRoutines
pthread.obj : error LNK2019: unresolved external symbol __imp_ResetEvent referenced in function __ptw32_cancelable_wait
pthread.obj : error LNK2019: unresolved external symbol __imp_ReleaseSemaphore referenced in function sem_post
pthread.obj : error LNK2019: unresolved external symbol __imp_WaitForSingleObject referenced in function __ptw32_callUserDestroyRoutines
pthread.obj : error LNK2019: unresolved external symbol __imp_CreateEventA referenced in function __ptw32_callUserDestroyRoutines
pthread.obj : error LNK2019: unresolved external symbol __imp_Sleep referenced in function __ptw32_callUserDestroyRoutines
pthread.obj : error LNK2019: unresolved external symbol __imp_WaitForMultipleObjects referenced in function __ptw32_cancelable_wait
pthread.obj : error LNK2019: unresolved external symbol __imp_GetCurrentProcess referenced in function __ptw32_getprocessors
pthread.obj : error LNK2019: unresolved external symbol __imp_GetCurrentProcessId referenced in function pthread_setaffinity_np
MSVCRT.lib(gs_support.obj) : error LNK2001: unresolved external symbol __imp_GetCurrentProcessId
pthread.obj : error LNK2019: unresolved external symbol __imp_GetCurrentThread referenced in function pthread_self
pthread.obj : error LNK2019: unresolved external symbol __imp_GetCurrentThreadId referenced in function pthread_self
...
MSVCRT.lib(gs_support.obj) : error LNK2019: unresolved external symbol __imp_QueryPerformanceCounter referenced in function __get_entropy
MSVCRT.lib(tncleanup.obj) : error LNK2019: unresolved external symbol __imp_InitializeSListHead referenced in function "void __cdecl __scrt_initialize_type_info(void)" (?__scrt_initialize_type_info@@YAXXZ)
MSVCRT.lib(utility_app.obj) : error LNK2019: unresolved external symbol __imp_RoInitialize referenced in function __scrt_initialize_winrt
MSVCRT.lib(cpu_disp.obj) : error LNK2019: unresolved external symbol IsProcessorFeaturePresent referenced in function __isa_available_init
pthreadVC3.dll : fatal error LNK1120: 40 unresolved externals

@strega-nil
Copy link
Copy Markdown
Contributor

fwiw, in the future you can do:

if(VCPKG_TARGET_IS_UWP)
    set(platform_patches fix-arm-uwp.patch)
endif()

vcpkg_from_sourceforge(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO pthreads4w
    FILENAME "pthreads4w-code-v${PTHREADS4W_VERSION}.zip"
    SHA512 49e541b66c26ddaf812edb07b61d0553e2a5816ab002edc53a38a897db8ada6d0a096c98a9af73a8f40c94283df53094f76b429b09ac49862465d8697ed20013
    PATCHES
        ${platform_patches}
)

@JackBoosY
Copy link
Copy Markdown
Contributor

Please add the following codes to ci.baseline.txt:

darknet:arm64-windows
darknet:arm-uwp
fontconfig:x64-uwp
fontconfig:arm-uwp
fontconfig:arm64-windows

@JackBoosY JackBoosY added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Mar 2, 2021
@luncliff
Copy link
Copy Markdown
Contributor Author

luncliff commented Apr 3, 2021

Fixed some collisions with #17011.

@JackBoosY
Copy link
Copy Markdown
Contributor

Please add clamav:arm64-windows=fail to scripts/ci.baseline.txt.

@luncliff
Copy link
Copy Markdown
Contributor Author

luncliff commented Apr 5, 2021

Please add clamav:arm64-windows=fail to scripts/ci.baseline.txt.

Thanks for the check, @JackBoosY. Applied in 34d4f9e :)

@vicroms vicroms merged commit b466bd5 into microsoft:master Apr 7, 2021
@luncliff luncliff deleted the port/pthreads branch April 8, 2021 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants