LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 43035 - apt packages have exports for FileCheck but don't ship it
Summary: apt packages have exports for FileCheck but don't ship it
Status: RESOLVED FIXED
Alias: None
Product: Build scripts
Classification: Unclassified
Component: cmake (show other bugs)
Version: 9.0
Hardware: PC Linux
: P normal
Assignee: Sylvestre Ledru
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-18 13:44 PDT by Stefan Gränitz
Modified: 2019-08-28 06:04 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
bionic llvm-8-dev (working) (45.79 KB, text/plain)
2019-08-28 02:35 PDT, Stefan Gränitz
Details
bionic llvm-9-dev (broken) (45.27 KB, text/plain)
2019-08-28 02:35 PDT, Stefan Gränitz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gränitz 2019-08-18 13:44:19 PDT

    
Comment 1 Stefan Gränitz 2019-08-18 13:54:23 PDT
Quick repro:

```
> docker pull weliveindetail/llvm09-apt-exports-repro:19.04
> docker run -it weliveindetail/llvm09-apt-exports-repro:19.04 /bin/bash
# cmake -G Ninja -B /home/jitfromscratch-release -DCMAKE_BUILD_TYPE=Release /home/jitfromscratch
[...]

CMake Error at /usr/lib/llvm-9/lib/cmake/llvm/LLVMExports.cmake:1335 (message):
  The imported target "FileCheck" references the file

     "/usr/lib/llvm-9/bin/FileCheck"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/llvm-9/lib/cmake/llvm/LLVMExports.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/llvm-9/cmake/LLVMConfig.cmake:245 (include)
  CMakeLists.txt:31 (find_package)
```


I created the image like this:
```
> docker run -it ubuntu:19.04
# apt-get update
# apt-get install -y --no-install-recommends ca-certificates wget gnupg software-properties-common
# wget https://apt.llvm.org/llvm-snapshot.gpg.key
# apt-key add llvm-snapshot.gpg.key
# apt-add-repository "deb http://apt.llvm.org/disco/ llvm-toolchain-disco-9 main"
# apt-get update
# apt-get install -y --no-install-recommends build-essential git cmake cmake-data ninja-build zlib1g-dev llvm-9-dev
# git clone https://github.com/weliveindetail/JitFromScratch.git /home/jitfromscratch
# cd /home/jitfromscratch
# git fetch origin llvm90/master
# git checkout llvm90/master
# cmake -G Ninja -B /home/jitfromscratch-release -DCMAKE_BUILD_TYPE=Release .
```
Comment 2 Stefan Gränitz 2019-08-18 14:02:29 PDT
How were the releases in the apt packages built? I can reproduce this on Ubuntu 18.04 and 19.04.

IIUC we shouldn't have FileCheck here (same for llvm-PerfectShuffle;count;not;yaml-bench?):

lib/cmake/llvm/LLVMConfig.cmake
244:  set(LLVM_EXPORTED_TARGETS ...;FileCheck;...)

lib/cmake/llvm/LLVMExports.cmake
19:foreach(_expectedTarget ...;FileCheck;...)
1083:# Create imported target FileCheck
1084:add_executable(FileCheck IMPORTED)

I remember having see this issue at some point. I can try to investigate for a few hours during the week.
Comment 3 Stefan Gränitz 2019-08-19 04:54:22 PDT
LLVM_INSTALL_UTILS=ON causes FileCheck and others to be listed in LLVMExports.cmake

Was it used to build the apt packages?
Comment 4 Hans Wennborg 2019-08-20 02:15:26 PDT
(In reply to Stefan Gränitz from comment #3)
> LLVM_INSTALL_UTILS=ON causes FileCheck and others to be listed in
> LLVMExports.cmake
> 
> Was it used to build the apt packages?

+Sylvestre who knows might know.
Comment 5 Stefan Gränitz 2019-08-25 08:23:06 PDT
Still reproducible
Comment 6 Sylvestre Ledru 2019-08-25 09:27:29 PDT
Yeah, I have been on holidays.
Don't hesitate to submit a patch next time ;)
Comment 7 Sylvestre Ledru 2019-08-25 09:49:52 PDT
I am not sure what you mean by "Don't ship it"

FileCheck is installed in the llvm-{7,8,9,...}-tools packages
Comment 8 Stefan Gränitz 2019-08-25 11:48:46 PDT
LLVMExports.cmake from the llvm-9-dev package lists FileCheck & co, but doesn't include the binaries for them.
Comment 9 Sylvestre Ledru 2019-08-25 12:32:55 PDT
Because it is shipped as part of llvm-9-tools
% dpkg -S FileCheck
[...]
llvm-9-tools: /usr/lib/llvm-9/bin/FileCheck

In command #1
just replace the install by
# apt-get install -y --no-install-recommends build-essential git cmake cmake-data ninja-build zlib1g-dev llvm-9-dev llvm-9-tools
Comment 10 Hans Wennborg 2019-08-27 07:31:08 PDT
Sylvestre: it's unclear to me if there is a problem here. Should the bug be marked wonfix? Or is there a dependency between packages missing?

In any case, I'm guessing this isn't a blocker for the release from the llvm side.
Comment 11 Stefan Gränitz 2019-08-28 02:35:01 PDT
Created attachment 22441 [details]
bionic llvm-8-dev (working)
Comment 12 Stefan Gränitz 2019-08-28 02:35:28 PDT
Created attachment 22442 [details]
bionic llvm-9-dev (broken)
Comment 13 Stefan Gränitz 2019-08-28 02:39:30 PDT
I attached the file in question. Please compare yourself if you want. If the change is on purpose, please explain how external projects are supposed to import LLVM from the apt release.
Comment 14 Sylvestre Ledru 2019-08-28 02:58:52 PDT
I am sorry but what should I see in the llvm-*-dev-LLVMExports.cmake files ?

Why don't you just add llvm-9-tools in the list of deps ?
Comment 15 Stefan Gränitz 2019-08-28 03:18:30 PDT
(In reply to Sylvestre Ledru from comment #14)
> I am sorry but what should I see in the llvm-*-dev-LLVMExports.cmake files ?

Please search both files for one of the following terms: FileCheck llvm-PerfectShuffle count not yaml-bench

> Why don't you just add llvm-9-tools in the list of deps ?

This is a regression. Building any project against llvm-9-dev fails with a CMake configuration error in `find_package(LLVM)`, because it wants to import a target that doesn't exist on disk. It worked perferctly well with llvm-8-dev.

If my project is too complicated, this CMakeLists.txt is enough to reproduce it:

```
cmake_minimum_required(VERSION 3.10)
project(PR43035)

find_package(LLVM)
```
Comment 16 Sylvestre Ledru 2019-08-28 04:57:08 PDT
OK
Seems it was cause by a change that you made here:
https://reviews.llvm.org/D56606

A fix would be indeed to add the deps
llvm-9-dev => llvm-9-tools (the package is small - 1.1M installed, so, I don't mind)

Stefan, would it make you happy?
Comment 17 Stefan Gränitz 2019-08-28 05:05:48 PDT
Thanks for finding that change.

As I mentioned earlier, the proper fix is: DO NOT BUILD the release with `LLVM_INSTALL_UTILS=ON` (default should be OFF). I tried that and it works as expected. Don't you think that's possible?

Whenever you build with `LLVM_INSTALL_UTILS=ON`, ship the utils in the same package please. IMHO adding a package dependency is a last resort.

I am on parental leave and I really can't spend more time here. I thought I'd report this quickly to avoid a release bug..
Comment 18 Sylvestre Ledru 2019-08-28 05:11:25 PDT
I had user requests to provide FileCheck.

See:
https://bugs.llvm.org/show_bug.cgi?id=27946
https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-3.8/+bug/1700630
And see this thread:
http://lists.llvm.org/pipermail/llvm-dev/2016-April/098233.html

(I removed them Tue, 08 Mar 2016 in 3.9~svn260851-1)

Merging two packages is a pain. I would rather add a dep
Comment 19 Stefan Gränitz 2019-08-28 05:51:28 PDT
I explained the problem and the solution in all possible ways. Don't know what else to say.
Comment 20 Sylvestre Ledru 2019-08-28 06:04:42 PDT
ok, thanks
anyway, clearly not a blocker for 9.0

fixed by adding a dep:
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/commit/cb79a639f54880bfe46167ea332210f3e3aac1a4