This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Fix a check that controls adding builtins to CMAKE_REQUIRED_LIBRARIES
Changes PlannedPublic

Authored by barannikov88 on Apr 1 2023, 3:51 AM.

Details

Summary

The condition was always false.

Diff Detail

Event Timeline

barannikov88 created this revision.Apr 1 2023, 3:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2023, 3:51 AM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
barannikov88 requested review of this revision.Apr 1 2023, 3:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2023, 3:51 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
barannikov88 edited the summary of this revision. (Show Details)Apr 1 2023, 3:52 AM
barannikov88 added reviewers: phosek, ldionne.
barannikov88 added inline comments.Apr 1 2023, 4:51 AM
compiler-rt/cmake/config-ix.cmake
238

This check is also broken, but I'm not sure how to fix it.
There is no arch variable in this scope, so ${arch} expands to nothing and
NOT MATCHES "avr|msp430" evaluates to false because there is no variable named NOT.

barannikov88 added inline comments.
compiler-rt/cmake/config-ix.cmake
238

I'd drop this if if there are no objections.
Targets that are interested in the value of the variable check it inside test_targets below.

phosek added inline comments.Apr 1 2023, 5:30 PM
compiler-rt/cmake/config-ix.cmake
44

I'm fine with this change as a cleanup, but this should behave identically. The change description says "The condition was always false." Where did you observe this?

238

I'd consider removing this entire check since I'm not sure whether it provides any value, but I'd do it in a separate change.

barannikov88 added inline comments.Apr 1 2023, 10:39 PM
compiler-rt/cmake/config-ix.cmake
44

I found it when porting compiler-rt for an out-of-tree target. It was probably unnoticed because it only affects checks like check_symbol_exists.

This should demonstrate the issue:

cmake_minimum_required(VERSION 3.20)

project(test)

execute_process(
  COMMAND which time
  OUTPUT_VARIABLE time
)
string(STRIP "${time}" time)
file(TO_CMAKE_PATH "${time}" time)

message(STATUS "time=${time}")

if (${time})
  message(STATUS "${time} is true")
else()
  message(STATUS "${time} is false")
endif()
-- time=/usr/bin/time
-- /usr/bin/time is false
barannikov88 added inline comments.Apr 10 2023, 9:05 AM
compiler-rt/cmake/config-ix.cmake
44

if (${VAR}) and if (VAR) behave identical for boolean values but not for string values.
This is because ON, True etc. are recognized by CMake, everything else is considered a variable name.
In this example, "/usr/bin/time" is a valid variable name, but there is no such variable, so it evaluates to false.

phosek added inline comments.Jun 15 2023, 11:57 PM
compiler-rt/cmake/config-ix.cmake
43–44

I think we should remove this condition altogether since PR51389 has already been addressed.

barannikov88 added inline comments.Jun 16 2023, 12:31 AM
compiler-rt/cmake/config-ix.cmake
43–44

Thanks for the heads-up, I'll see what I can do

barannikov88 added inline comments.Jun 24 2023, 2:41 AM
compiler-rt/cmake/config-ix.cmake
43–44

I think we should remove this condition altogether since PR51389 has already been addressed.

It is still open though https://github.com/llvm/llvm-project/issues/50731
Could you point me to the commit that addressed the issue? At quick glance the issue is still there.

phosek added inline comments.Jun 30 2023, 5:07 PM
compiler-rt/cmake/config-ix.cmake
43–44

It was addressed in https://reviews.llvm.org/D88458.

barannikov88 planned changes to this revision.Jun 30 2023, 6:03 PM
barannikov88 added inline comments.
compiler-rt/cmake/config-ix.cmake
43–44

Thanks!

ldionne resigned from this revision.Aug 31 2023, 9:11 AM