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

[vcpkg] Set CMAKE_SYSTEM_PROCESSOR if target architecture is arm-linux or arm64-linux. #13465

Merged
merged 1 commit into from
Oct 17, 2020

Conversation

x-projs
Copy link
Contributor

@x-projs x-projs commented Sep 10, 2020

Describe the pull request

This change tries to fix issue #13395.

Root cause:
In script mode, cmake won't populate CMAKE_SYSTEM_PROCESSOR parameter automatically. That parameter is
required by libpng to configure build parameters. To fix this issue, we need explicitly set CMAKE_SYSTEM_PROCESSOR
value.

Verify:
On arm64-linux host, run ./vcpkg install tesseract:arm64-linux.

@JackBoosY JackBoosY self-assigned this Sep 11, 2020
@Neumann-A
Copy link
Contributor

This belongs in the CMake toolchain not the triplet....

@JackBoosY
Copy link
Contributor

Agreed with @Neumann-A.

@x-projs
Copy link
Contributor Author

x-projs commented Sep 11, 2020

To me, CMAKE_SYSTEM_PROCESSOR is an alias of VCPKG_TARGET_ARCHITECTURE. If VCPKG_TARGET_ARCHITECTURE belongs to the triplet, why does CMAKE_SYSTEM_PROCESSOR not?

@Neumann-A
Copy link
Contributor

To me, CMAKE_SYSTEM_PROCESSOR is an alias of VCPKG_TARGET_ARCHITECTURE.

bad design to double down on the same thing especially since VCPKG_TARGET_ARCHITECTURE is basically a global variable while CMAKE_SYSTEM_PROCESSOR only applies to CMake.

Furthermore if you compile your outside project for that system you probably have a toolchain setting all the values and compiler flags correctly. As such you can just use that toolchain within vcpkg and be done with it instead of repeating yourself in the triplet.

@x-projs
Copy link
Contributor Author

x-projs commented Sep 11, 2020

Updated. Change is moved to scripts/toolchains/linux.cmake. I found that we had set CMAKE_SYSTEM_PROCESSOR for x86 and x86_64 in that file. So I think it is also a right place to set for arm and arm64. CMAKE_SYSTEM_PROCESSOR is needed for all systems, not just linux, so the best place might be vcpkg_configure_cmake.cmake? Maybe it's worth to discuss further. Currently, I think just following the old pattern is not bad.

@JackBoosY JackBoosY added the category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed label Sep 14, 2020
@JackBoosY JackBoosY requested a review from dan-shaw September 14, 2020 02:27
@x-projs x-projs changed the title [vcpkg] Pass CMAKE_SYSTEM_PROCESSOR and CMAKE_HOST_SYSTEM_PROCESSOR to _csc_OPTIONS. [vcpkg] Set CMAKE_SYSTEM_PROCESSOR if target architecture is arm-linux or arm64-linux. Sep 15, 2020
@ras0219-msft
Copy link
Contributor

/azp run

@ras0219-msft
Copy link
Contributor

ras0219-msft commented Sep 15, 2020

This PR LGTM once we get the CI to pass :) Thanks!

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Neumann-A
Copy link
Contributor

Something similar needs to be applied to windows based arm triplets

@JackBoosY JackBoosY added info:reviewed Pull Request changes follow basic guidelines requires:discussion and removed requires:discussion labels Sep 16, 2020
@BillyONeal
Copy link
Member

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@BillyONeal
Copy link
Member

This broke openxr-loader:

CMake Error: install(EXPORT "openxr_loader_export" ...) includes target "openxr_loader" which requires target "jsoncpp_interface" that is not in any export set.
CMake Error in src/loader/CMakeLists.txt:
  export called with target "openxr_loader" which requires target
  "jsoncpp_interface" that is not in any export set.

@BillyONeal BillyONeal added requires:author-response and removed info:reviewed Pull Request changes follow basic guidelines labels Oct 8, 2020
@x-projs
Copy link
Contributor Author

x-projs commented Oct 12, 2020

@BillyONeal, seems this build failed on vcpkg/master already.

xyb@ubuntu:~/src/vcpkg2$ ./vcpkg install openxr-loader
Your feedback is important to improve Vcpkg! Please take 3 minutes to complete our survey by running: vcpkg contact --survey
Computing installation plan...
The following packages will be built and installed:
    openxr-loader[core]:x64-linux
Detecting compiler hash for triplet x64-linux...
Starting package 1/1: openxr-loader:x64-linux
Building package openxr-loader[core]:x64-linux...
Could not locate cached archive: /home/xyb/.cache/vcpkg/archives/13/13e0de973fe88aad24e157acf79e4ef5d171ca09.zip
-- Using cached /home/xyb/src/vcpkg2/downloads/KhronosGroup-OpenXR-SDK-e3a4e41d61544d8e2eba73f00da99b6818ec472b.tar.gz
-- Cleaning sources at /home/xyb/src/vcpkg2/buildtrees/openxr-loader/src/6818ec472b-d1dc3815be.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source /home/xyb/src/vcpkg2/downloads/KhronosGroup-OpenXR-SDK-e3a4e41d61544d8e2eba73f00da99b6818ec472b.tar.gz
-- Using source at /home/xyb/src/vcpkg2/buildtrees/openxr-loader/src/6818ec472b-d1dc3815be.clean
-- Using cached /home/xyb/src/vcpkg2/downloads/KhronosGroup-OpenXR-SDK-Source-6dee6e228f47857adf5d7673eb90c64f04d33c60.tar.gz
-- Cleaning sources at /home/xyb/src/vcpkg2/buildtrees/openxr-loader/src/4f04d33c60-d722ef33b7.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source /home/xyb/src/vcpkg2/downloads/KhronosGroup-OpenXR-SDK-Source-6dee6e228f47857adf5d7673eb90c64f04d33c60.tar.gz
-- Using source at /home/xyb/src/vcpkg2/buildtrees/openxr-loader/src/4f04d33c60-d722ef33b7.clean
-- Using cached /home/xyb/src/vcpkg2/downloads/KhronosGroup-OpenXR-hpp-097a7535563fc84bb7648ea9c5a4531a1e909458.tar.gz
-- Cleaning sources at /home/xyb/src/vcpkg2/buildtrees/openxr-loader/src/1a1e909458-6946dc9d31.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source /home/xyb/src/vcpkg2/downloads/KhronosGroup-OpenXR-hpp-097a7535563fc84bb7648ea9c5a4531a1e909458.tar.gz
-- Using source at /home/xyb/src/vcpkg2/buildtrees/openxr-loader/src/1a1e909458-6946dc9d31.clean
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:141 (message):
    Command failed: /home/xyb/src/vcpkg2/downloads/tools/cmake-3.17.2-linux/cmake-3.17.2-Linux-x86_64/bin/cmake --build . --config Debug --target install -- -v -j65
    Working Directory: /home/xyb/src/vcpkg2/buildtrees/openxr-loader/x64-linux-dbg
    See logs for more information:
      /home/xyb/src/vcpkg2/buildtrees/openxr-loader/install-x64-linux-dbg-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_build_cmake.cmake:92 (vcpkg_execute_build_process)
  scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
  ports/openxr-loader/portfile.cmake:52 (vcpkg_install_cmake)
  scripts/ports.cmake:79 (include)


**Error: Building package openxr-loader:x64-linux failed with: BUILD_FAILED**
Please ensure you're using the latest portfiles with `./vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: openxr-loader:x64-linux
  Vcpkg version: 2020.06.15-unknownhash

Additionally, attach any relevant sections from the log files above.
xyb@ubuntu:~/src/vcpkg2$ git log --oneline
**37c412ae0 (HEAD -> vcpkg-master, vcpkg/master) [osg] Fix feature plugin (#13942)**
3714469e0 [gcem] Update to version 1.13.1 (#13895)
54e7948c7 [mikktspace] Initial port (#13900)
dea7dbb19 [drogon] Update to 1.0.0 (#13907)
032f3e29c [freeimage] Fix macOS build error (#13916)

@x-projs
Copy link
Contributor Author

x-projs commented Oct 12, 2020

@BillyONeal , figured out the issue. That lib depends on another library (libxcb-glx0-dev), after run sudo apt-get install libxcb-glx0-dev, build success. It's not related to my PR.

@JackBoosY
Copy link
Contributor

@xieyubo We already installed that before the pipeline check.
See

libxcb1-dev libx11-xcb-dev libxcb-glx0-dev"

@x-projs
Copy link
Contributor Author

x-projs commented Oct 14, 2020

@JackBoosY , still didn't repro on a clean environment:

xyb@xybpc:~/src/vcpkg$ ./vcpkg install openxr-loader
Computing installation plan...
The following packages will be built and installed:
openxr-loader[core]:x64-linux
Detecting compiler hash for triplet x64-linux...
Starting package 1/1: openxr-loader:x64-linux
Building package openxr-loader[core]:x64-linux...
Could not locate cached archive: /home/xyb/.cache/vcpkg/archives/4d/4d7effa59a6a926bfcbc43c8890d66b32f9361fa.zip
-- Downloading https://github.com/KhronosGroup/OpenXR-SDK/archive/e3a4e41d61544d8e2eba73f00da99b6818ec472b.tar.gz...
-- Extracting source /home/xyb/src/vcpkg/downloads/KhronosGroup-OpenXR-SDK-e3a4e41d61544d8e2eba73f00da99b6818ec472b.tar.gz
-- Using source at /home/xyb/src/vcpkg/buildtrees/openxr-loader/src/6818ec472b-d1dc3815be.clean
-- Downloading https://github.com/KhronosGroup/OpenXR-SDK-Source/archive/6dee6e228f47857adf5d7673eb90c64f04d33c60.tar.gz...
-- Extracting source /home/xyb/src/vcpkg/downloads/KhronosGroup-OpenXR-SDK-Source-6dee6e228f47857adf5d7673eb90c64f04d33c60.tar.gz
-- Using source at /home/xyb/src/vcpkg/buildtrees/openxr-loader/src/4f04d33c60-d722ef33b7.clean
-- Downloading https://github.com/KhronosGroup/OpenXR-hpp/archive/097a7535563fc84bb7648ea9c5a4531a1e909458.tar.gz...
-- Extracting source /home/xyb/src/vcpkg/downloads/KhronosGroup-OpenXR-hpp-097a7535563fc84bb7648ea9c5a4531a1e909458.tar.gz
-- Using source at /home/xyb/src/vcpkg/buildtrees/openxr-loader/src/1a1e909458-6946dc9d31.clean
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Applying patch 001-fix-array-decl.patch
-- Installing: /home/xyb/src/vcpkg/packages/openxr-loader_x64-linux/share/openxr-loader/copyright
-- Performing post-build validation
-- Performing post-build validation done
sh: 1: zip: not found
Failed to store binary cache /home/xyb/.cache/vcpkg/archives/4d/4d7effa59a6a926bfcbc43c8890d66b32f9361fa.zip: No such file or directory
Building package openxr-loader[core]:x64-linux... done
Installing package openxr-loader[core]:x64-linux...
Installing package openxr-loader[core]:x64-linux... done
Elapsed time for package openxr-loader:x64-linux: 24.44 s

Total elapsed time: 25.48 s

The package openxr-loader:x64-linux provides CMake targets:

find_package(OpenXR CONFIG REQUIRED)
target_link_libraries(main PRIVATE OpenXR::headers OpenXR::openxr_loader OpenXR::openxr-all-supported)

@x-projs
Copy link
Contributor Author

x-projs commented Oct 14, 2020

OK, repro it. The repro step:

./vcpkg install jsoncpp
./vcpkg install openxr-loader

@x-projs
Copy link
Contributor Author

x-projs commented Oct 14, 2020

I think it is a separate issue not related to my PR. Even in vcpkg master build, if you install jsoncpp package first, then install openxr-loader, you will hit the same issue. But if you install openxr-loader before jsoncpp, you won't hit this issue. @JackBoosY @BillyONeal

…E is arm or arm64.

This change tries to fix issue microsoft#13395.

Root cause:
In script mode, cmake won't populate CMAKE_SYSTEM_PROCESSOR parameter automatically. That parameter is
required by libpng to configure build parameters. To fix this issue, we need explicitly set CMAKE_SYSTEM_PROCESSOR
value.

Verify:
On arm64-linux host, run `./vcpkg install tesseract:arm64-linux`.
@x-projs
Copy link
Contributor Author

x-projs commented Oct 14, 2020

I noticed @PhoebeHui just fixed the openxr-loader build dependency issue: 790910f. I've rebased with his change. I believe my PR should be pass now. @BillyONeal

@JackBoosY JackBoosY added the info:reviewed Pull Request changes follow basic guidelines label Oct 16, 2020
@dan-shaw dan-shaw merged commit 27a2418 into microsoft:master Oct 17, 2020
@x-projs x-projs deleted the fix-13395 branch October 17, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants