Skip to content

cmake/llvm: Don't unset LLVM_CONFIG_EXE - #19971

Merged
andrewrk merged 1 commit into
ziglang:masterfrom
beholders-eye:beholders-eye/rever-unset-llvm-config-exe
May 20, 2024
Merged

cmake/llvm: Don't unset LLVM_CONFIG_EXE#19971
andrewrk merged 1 commit into
ziglang:masterfrom
beholders-eye:beholders-eye/rever-unset-llvm-config-exe

Conversation

@beholders-eye

Copy link
Copy Markdown

Left a comment in #12136, asking why we decided to unset LLVM_CONFIG_EXE.

@nektro

nektro commented May 15, 2024

Copy link
Copy Markdown
Contributor

I think it'd be better to let ZIG_USE_LLVM_CONFIG be overwritten in the root cmake file

@BratishkaErik

BratishkaErik commented May 15, 2024

Copy link
Copy Markdown
Contributor

Left a comment in #12136, asking why we decided to unset LLVM_CONFIG_EXE.

You can add -DCMAKE_PREFIX_PATH="${where_is_llvm_bin_and_libraries", but I too don't know why we unset it.

I think it'd be better to let ZIG_USE_LLVM_CONFIG be overwritten in the root cmake file

It's already can be overwritten.

@BratishkaErik

Copy link
Copy Markdown
Contributor

Is it for Exherbo's dev-lang/zig BTW? Just looked at your repositories on GitHub, I can share my (not published yet) 0.12.0 updates for Gentoo here if you want, there should be something helpful for Exherbo too

@beholders-eye

Copy link
Copy Markdown
Author

Is it for Exherbo's dev-lang/zig BTW? Just looked at your repositories on GitHub, I can share my (not published yet) 0.12.0 updates for Gentoo here if you want, there should be something helpful for Exherbo too

Yes, please. Thank you.

@andrewrkandrewrk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is not obvious why to unset, and there is no comment explaining why, it can be removed, and if it needs to be added back then it should come with a comment explaining why.

@andrewrk
andrewrk enabled auto-merge (rebase) May 20, 2024 16:01
@andrewrk
andrewrk merged commit 28476a5 into ziglang:masterMay 20, 2024
@beholders-eye
beholders-eye deleted the beholders-eye/rever-unset-llvm-config-exe branch May 21, 2024 13:50
@Snektron

Copy link
Copy Markdown
Collaborator

I found out why: At least on my machine, cmake hangs without this when the right LLVM version is not found.

@rohlem

rohlem commented May 24, 2024

Copy link
Copy Markdown
Contributor

In my understanding, to answer what the unset is supposed to do:

  • There is a while(1) loop that wants to find the right version of llvm-confighere.
  • To do this, it looks for llvm-config using find_program, then performs a bunch of checks.
  • If one of the checks fails, it appends the found directory path to an ignore list, then continues the while loop.
    It seems like this approach was approved in the previous post-merge comment.
  • It seems like if we don't unset the variable, the same result is returned even though the ignore list has changed.
  • This leads to the configure process not terminating as @Snektron pointed out.

Unsetting the variable seems critical on the paths that continue().
A solution to allow a user-specified LLVM_CONFIG_EXE would then be to either not unset in the first iteration of the loop (use a local variable? I know nothing about CMake) or copy-paste the unset before every continue().
It would probably be better to abort if the user-specified LLVM_CONFIG_EXE fails one of the checks though, instead of ignoring it and looking in other paths.
So a local variable to see whether it was user-supplied seems the best to me (but again I know nothing about CMake).
Adding an explanatory comment either way would be beneficial.

@andrewrk

Copy link
Copy Markdown
Member

OK let's have it back with a comment explaining its purpose then please

@andrewrk

Copy link
Copy Markdown
Member

Reverted in 793f820

@beholders-eye

Copy link
Copy Markdown
Author

It would probably be better to abort if the user-specified LLVM_CONFIG_EXE fails one of the checks though, instead of ignoring it and looking in other paths.

That was my main reason for removing it in this PR. Was this done in 0.13?

@beholders-eye

Copy link
Copy Markdown
Author

It would probably be better to abort if the user-specified LLVM_CONFIG_EXE fails one of the checks though, instead of ignoring it and looking in other paths.

That was my main reason for removing it in this PR. Was this done in 0.13?

Fixed the build locally by setting -Dllvm_ROOT, all good. Thanks for all the insights and replies guys 🙌🏼 .

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@beholders-eye@nektro@BratishkaErik@Snektron@rohlem@andrewrk