Skip to content

BUG: openmp/cmake/HandleOpenMPOptions.cmake uses CMake function append without defining it #80117

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

Closed
h-vetinari opened this issue Jan 31, 2024 · 13 comments · Fixed by #80174
Closed
Assignees
Labels
cmake Build system in general and CMake in particular openmp release:backport

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Jan 31, 2024

While building openmp 18.1.0-rc1 on windows, I get:

CMake Error at cmake/HandleOpenMPOptions.cmake:47 (append):
  Unknown CMake command "append".

This is due to https://github.com/llvm/llvm-project/blame/release/18.x/openmp/cmake/HandleOpenMPOptions.cmake using append since 15fdc76, but not defining it -- in contrast to append_if which explicitly duplicates the definition from HandleLLVMOptions.cmake:

if (NOT COMMAND append_if)
# From HandleLLVMOptions.cmake
function(append_if condition value)
if (${condition})
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endif()
endfunction()
endif()

I don't know why this file does not (or cannot) do include(HandleLLVMOptions), but if that's not an option, then it needs to similarly vendor the definition of append.

CC @aganea

@aganea aganea self-assigned this Jan 31, 2024
@aganea
Copy link
Member

aganea commented Jan 31, 2024

Thanks for the report, I will take a look today.

@aganea
Copy link
Member

aganea commented Jan 31, 2024

Could you also please explain what cmake version are you using and the arguments used to build LLVM?

@EugeneZelenko EugeneZelenko added cmake Build system in general and CMake in particular openmp and removed new issue labels Jan 31, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 31, 2024

@llvm/issue-subscribers-openmp

Author: None (h-vetinari)

While [building](https://github.com/conda-forge/openmp-feedstock/pull/113) openmp 18.1.0-rc1 on windows, I get: ``` CMake Error at cmake/HandleOpenMPOptions.cmake:47 (append): Unknown CMake command "append". ```

This is due to https://github.com/llvm/llvm-project/blame/release/18.x/openmp/cmake/HandleOpenMPOptions.cmake using append since 15fdc76, but not defining it -- in contrast to append_if which explicitly duplicates the definition from HandleLLVMOptions.cmake:

if (NOT COMMAND append_if)
# From HandleLLVMOptions.cmake
function(append_if condition value)
if (${condition})
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endif()
endfunction()
endif()

I don't know why this file does not (or cannot) do include(HandleLLVMOptions), but if that's not an option, then it needs to similarly vendor the definition of append.

CC @aganea

@h-vetinari
Copy link
Contributor Author

h-vetinari commented Jan 31, 2024

Could you also please explain what cmake version are you using and the arguments used to build LLVM?

We use the newest available CMake (3.28.2) and the main build invocation is:

cd openmp
mkdir build
cd build

cmake -G "Ninja" ^
    -DCMAKE_BUILD_TYPE="Release" ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% ^
    ..

The truth is slightly more complicated (for various reasons incl. CI limitations, we build LLVM component-wise; originally that was done with the subproject tarballs, now we ensure that just ./openmp and ./cmake are in the source directory). Most importantly, we build against an already-built llvm library that lives in %LIBRARY_PREFIX%.

Edit: fixed a braino in referring to the wrong component

@h-vetinari
Copy link
Contributor Author

Thanks for the report, I will take a look today.

Thank you for the quick response! 🙏

@jhuber6
Copy link
Contributor

jhuber6 commented Jan 31, 2024

IIRC the reason we can't just include(LLVM) is because we somewhat support a standalone usage. I.e. you can just get openmp and build it through CMake if you have an LLVM installation somewhere on your system.

@h-vetinari
Copy link
Contributor Author

IIRC the reason we can't just include(LLVM) is because we somewhat support a standalone usage. I.e. you can just get openmp and build it through CMake if you have an LLVM installation somewhere on your system.

I mean, the waters have muddied on this substantially in recent years, c.f. here and here. My understanding of the former is that using /cmake is allowed in /openmp, and not in conflict with the standalone builds. CC @tstellar as RFC author.

I do care about building openmp "standalone", but I don't mind if I need to provide the corresponding CMake sources alongside (this has been the status quo for several other subprojects as well).

@shiltian
Copy link
Contributor

Even so, host OpenMP still supports standalone build w/o LLVM. That's why we are pretty careful about adding dependencies for libomp. libomptarget is completely a LLVM library, which is beyond the scope here.

aganea added a commit to aganea/llvm-project that referenced this issue Jan 31, 2024
@aganea
Copy link
Member

aganea commented Jan 31, 2024

@h-vetinari Can you check please if #80174 fixes the issue?

@h-vetinari
Copy link
Contributor Author

Thanks a lot @aganea! Tested the state of this patch on top of the release/18.x branch, and it works! 🙏

@aganea
Copy link
Member

aganea commented Feb 1, 2024

/cherry-pick d2565bb

llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Feb 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 1, 2024

/pull-request #80291

@EugeneZelenko EugeneZelenko reopened this Feb 1, 2024
smithp35 pushed a commit to smithp35/llvm-project that referenced this issue Feb 1, 2024
carlosgalvezp pushed a commit to carlosgalvezp/llvm-project that referenced this issue Feb 1, 2024
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Feb 2, 2024
@tstellar tstellar moved this from Needs Triage to Done in LLVM Release Status Feb 2, 2024
@tstellar
Copy link
Collaborator

tstellar commented Feb 2, 2024

PR has been created, we will track the status there.

@tstellar tstellar closed this as completed Feb 2, 2024
agozillon pushed a commit to agozillon/llvm-project that referenced this issue Feb 5, 2024
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
tstellar pushed a commit to tstellar/llvm-project that referenced this issue Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular openmp release:backport
Projects
Development

Successfully merging a pull request may close this issue.

7 participants