Bug 223191 - devel/llvm*: --link-shared is broken
Summary: devel/llvm*: --link-shared is broken
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Brooks Davis
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2017-10-23 16:14 UTC by Jan Beich
Modified: 2019-07-15 19:50 UTC (History)
5 users (show)

See Also:
jbeich: maintainer-feedback? (brooks)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2017-10-23 16:14:20 UTC
Mesa 17.3 wants to use --link-shared for LLVM >= 3.9 but it seems to be broken downstream.

https://cgit.freedesktop.org/mesa/mesa/commit/?id=13a53c4f5cdd

$ pkg install llvm40
$ llvm-config40 --link-shared --libs
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMDemangle.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSupport.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMCore.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMProfileData.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBitReader.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMC.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMCParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMObject.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAnalysis.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBitWriter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMTransformUtils.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMInstCombine.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMIRReader.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLinker.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMScalarOpts.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMVectorize.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMInstrumentation.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMipo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMCoroutines.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMTarget.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMRuntimeDyld.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMExecutionEngine.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMInterpreter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLineEditor.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMCJIT.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86Utils.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86AsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86Info.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMCDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86Desc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMDebugInfoMSF.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMDebugInfoCodeView.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSelectionDAG.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMGlobalISel.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86CodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86AsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMX86Disassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMOption.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLibDriver.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMObjectYAML.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64Utils.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64AsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64Info.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64Desc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64AsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64CodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAArch64Disassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUUtils.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMAMDGPUDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMARMAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMARMInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMARMDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMARMAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMARMCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMARMDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBPFAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBPFInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBPFDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBPFCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMBPFDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMHexagonInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMHexagonDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMHexagonAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMHexagonCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMHexagonDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLanaiInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLanaiInstPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLanaiDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLanaiAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLanaiCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLanaiDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMipsAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMipsInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMipsDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMipsAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMipsCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMipsDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMSP430AsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMSP430Info.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMSP430Desc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMSP430CodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMNVPTXAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMNVPTXInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMNVPTXDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMNVPTXCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPowerPCAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPowerPCInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPowerPCDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPowerPCAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPowerPCCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPowerPCDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMRISCVInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMRISCVCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMRISCVDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSparcAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSparcInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSparcDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSparcAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSparcCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSparcDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSystemZAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSystemZInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSystemZDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSystemZAsmParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSystemZCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSystemZDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMXCoreAsmPrinter.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMXCoreInfo.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMXCoreDesc.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMXCoreCodeGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMXCoreDisassembler.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMOrcJIT.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMTableGen.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMCoverage.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMDebugInfoDWARF.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMDebugInfoPDB.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMSymbolize.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMMIRParser.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMObjCARCOpts.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMPasses.so
llvm-config: error: missing: /usr/local/llvm40/lib/libLLVMLTO.so
Comment 1 Greg V 2017-12-10 14:17:57 UTC
Trying to get Meson build working in Mesa git master, same problem. Actually it doesn't use --link-shared, it uses default (which is static for some reason).

And even static is broken. Meson doesn't use --system-libs anymore https://github.com/mesonbuild/meson/pull/2443/files but even if I add that back:

$ llvm-config50 --system-libs
-lrt -l/usr/lib/libexecinfo.so -ltinfo -lpthread -lz -lm

/usr/bin/ld: cannot find -l/usr/lib/libexecinfo.so

How is *anything* working with such broken llvm-config?? o_0
Comment 2 Greg V 2017-12-19 15:01:06 UTC
Just encountered the -l/usr/lib/libexecinfo.so problem when building the Crystal compiler with llvm50. This didn't happen before!! llvm40 worked…
Comment 3 Greg V 2017-12-24 13:19:53 UTC
Okay I found where the execinfo full path comes from!!

https://github.com/Kitware/CMake/blob/40dea7e4b2e1c4518337bba284a233bf6f788a1a/Modules/FindBacktrace.cmake#L75

A quick fix is to change that line to: set(Backtrace_LIBRARY "execinfo")

But it seems like having a full path there is correct from CMake's point of view, llvm-config just turns the CMake variables into linker flags wrong.
Comment 4 Greg V 2017-12-25 16:01:37 UTC
Oh and to fix shared link, add:

CMAKE_ARGS+=   -DLLVM_LINK_LLVM_DYLIB=ON

after:

CMAKE_ARGS=    -DLLVM_BUILD_LLVM_DYLIB=ON

Turns out if you build the monolithic dylib (libLLVM-5.0.so) but don't link it, llvm-config will assume you actually have the tiny separate libs. ¯\_(ツ)_/¯
Comment 5 Greg V 2017-12-26 18:44:42 UTC
Looks like we have some awkward workarounds coming…

'.replace("-l/usr/lib/libexecinfo.so","-lexecinfo")' @ https://github.com/freebsd/freebsd-ports/commit/6ef96cb042430f118614feefd97a411ba22838a4

This should be fixed on cmake/llvm level, not in llvm consumers…
Comment 6 commit-hook freebsd_committer 2018-01-10 01:44:17 UTC
A commit references this bug:

Author: brooks
Date: Wed Jan 10 01:43:37 UTC 2018
New revision: 458590
URL: https://svnweb.freebsd.org/changeset/ports/458590

Log:
  Upgrade to 5.0.1.

  Correct shared linkage with llvm-config50.[0]

  PR:		223191 [0]
  Submitted by:	greg@unrelenting.technology
  MFH:		2008Q1

Changes:
  head/devel/llvm50/Makefile
  head/devel/llvm50/distinfo
Comment 7 commit-hook freebsd_committer 2018-01-10 04:03:06 UTC
A commit references this bug:

Author: brooks
Date: Wed Jan 10 04:02:22 UTC 2018
New revision: 458596
URL: https://svnweb.freebsd.org/changeset/ports/458596

Log:
  Correct llvm-config40 output with shared libraries.

  PR:		223191
  Submitted by:	greg@unrelenting.technology
  MFH:		2018Q1

Changes:
  head/devel/llvm40/Makefile
Comment 8 Brooks Davis freebsd_committer 2018-01-10 04:08:02 UTC
Seems to be fixed other than merging to 2018Q1.
Comment 9 Antoine Brodin freebsd_committer 2018-01-10 07:01:29 UTC
I reverted the upgrade,  it's unfetchable.
Comment 10 Barbara Guida freebsd_committer 2018-01-10 09:46:28 UTC
(In reply to Antoine Brodin from comment #9)
I have it build overnight, fetched at 3:11 AM (CET).
I repeated some test with curl -I for every file in distfiles and now it seems still fetchable.
Comment 11 Brooks Davis freebsd_committer 2018-01-10 17:01:26 UTC
(In reply to Antoine Brodin from comment #9)

What errors are you seeing?
Comment 12 Brooks Davis freebsd_committer 2018-01-10 17:26:16 UTC
Reopen due to revert in llvm50.
Comment 13 commit-hook freebsd_committer 2018-01-10 19:22:38 UTC
A commit references this bug:

Author: brooks
Date: Wed Jan 10 19:21:50 UTC 2018
New revision: 458680
URL: https://svnweb.freebsd.org/changeset/ports/458680

Log:
  Upgrade to 5.0.1.

  Add a local distfile backup while LLVM sorts out mirror issues.

  Correct shared linkage with llvm-config50.[0]

  PR:		223191 [0]
  Submitted by:	greg@unrelenting.technology [0]
  MFH:		2018Q1

Changes:
  head/devel/llvm50/Makefile
  head/devel/llvm50/distinfo
Comment 14 Brooks Davis freebsd_committer 2018-01-10 19:24:15 UTC
Recommitted with local dist backup.
Comment 15 commit-hook freebsd_committer 2018-02-02 10:09:01 UTC
A commit references this bug:

Author: feld
Date: Fri Feb  2 10:08:36 UTC 2018
New revision: 460693
URL: https://svnweb.freebsd.org/changeset/ports/460693

Log:
  MFH: r458590

  Upgrade to 5.0.1.

  Correct shared linkage with llvm-config50.[0]

  PR:		223191 [0]
  Submitted by:	greg@unrelenting.technology

Changes:
_U  branches/2018Q1/
  branches/2018Q1/devel/llvm50/Makefile
  branches/2018Q1/devel/llvm50/distinfo
Comment 16 commit-hook freebsd_committer 2018-02-02 10:10:05 UTC
A commit references this bug:

Author: feld
Date: Fri Feb  2 10:09:19 UTC 2018
New revision: 460694
URL: https://svnweb.freebsd.org/changeset/ports/460694

Log:
  MFH: r458596

  Correct llvm-config40 output with shared libraries.

  PR:		223191
  Submitted by:	greg@unrelenting.technology

Changes:
_U  branches/2018Q1/
  branches/2018Q1/devel/llvm40/Makefile
Comment 17 Jan Beich freebsd_committer 2019-07-12 18:59:45 UTC
Brooks, can you apply the same fix to devel/llvm-devel as well?

$ llvm-config-devel --link-shared --libs
OMP: Info #270: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
llvm-config: error: missing: /usr/local/llvm-devel/lib/libLLVMDemangle.so
llvm-config: error: missing: /usr/local/llvm-devel/lib/libLLVMSupport.so
llvm-config: error: missing: /usr/local/llvm-devel/lib/libLLVMBinaryFormat.so
llvm-config: error: missing: /usr/local/llvm-devel/lib/libLLVMRemarks.so
llvm-config: error: missing: /usr/local/llvm-devel/lib/libLLVMCore.so
[...]
Comment 18 Jan Beich freebsd_committer 2019-07-12 21:28:39 UTC
Also, Clang has a separate knob as of LLVM 9.0.

https://github.com/llvm/llvm-project/commit/2e97d2aa1bd3
Comment 19 commit-hook freebsd_committer 2019-07-15 19:50:41 UTC
A commit references this bug:

Author: brooks
Date: Mon Jul 15 19:49:52 UTC 2019
New revision: 506706
URL: https://svnweb.freebsd.org/changeset/ports/506706

Log:
  Upgrade to a newer snapshot.

  Chase the switch to python 3.6 as default.

  Enable LLVM_LINK_LLVM_DYLIB and CLANG_LINK_LLVM_DYLIB.[0]

  PR:		223191 [0]
  Requested by:	jbeich [0]

Changes:
  head/devel/llvm-devel/Makefile
  head/devel/llvm-devel/Makefile.snapshot
  head/devel/llvm-devel/distinfo
  head/devel/llvm-devel/pkg-plist