Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,296
    • Issues 3,296
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 9
    • Merge Requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #21725

Closed
Open
Created Jan 20, 2021 by Steven B@Steve132

FindOpenMP.cmake needs to be patched on Android NDK wrt clang.

Android as of NDK r20 does not have support for gcc except through Clang.

https://android.googlesource.com/platform/ndk/+/master/docs/ClangMigration.md

However, modern versions of Clang on android inside the NDK no longer provide dynamic linking capability for openmp.

https://github.com/android/ndk/issues/1028

https://github.com/Tencent/ncnn/issues/1771

https://github.com/llvm-project/llvm-project-submodule/commit/67728311735cf648591938e8e2ac2f864b8ed140

When a project is build on android with -fopenmp, it builds, but it fails at runtime with "dlopen cannot open libomp.so" https://github.com/Tencent/ncnn/issues/1771 because dynamic libomp is no longer supported.

The required fix for this on android is to add -static-omp on Android versions of clang that support that flag, or to add "-Wl,-Bstatic -lomp -Wl,-Bdynamic" on versions of clang that do not.

https://github.com/android/ndk/issues/1028#issuecomment-524481843

This should be handled internally by FindOpenMP.cmake on platforms where it is relevant: e.g., if -static-omp is required by the local clang platform (initially, Android) and libomp.so is not enabled on the target platform, then OpenMP::OpenMP public link settings should include the correct flag to enable static linking without further intervention by the user.

This issue recently cost me about 8 hours to resolve and debug.

I will write a patch to do this if needed

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None