Bug 244403 - databases/postgresql11-server: Fix build with clang 10.0.0
Summary: databases/postgresql11-server: Fix build with clang 10.0.0
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: pgsql
URL:
Keywords:
Depends on:
Blocks: 244251
  Show dependency treegraph
 
Reported: 2020-02-25 18:02 UTC by Dimitry Andric
Modified: 2020-07-04 01:39 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (pgsql)


Attachments
Ensure postgresl-server ports use clang90 (782 bytes, patch)
2020-02-25 19:08 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2020-02-25 18:02:24 UTC
As reported in bug 244251, with clang 10.0.0 the databases/postgresql11-server port fails to build with a fatal llvm-lto error:

cd '/wrkdirs/usr/ports/databases/postgresql11-server/work/stage/usr/local/lib/postgresql/bitcode' && /usr/local/llvm90/bin/llvm-lto -thinlto -thinlto-action=thinlink -o postgres.index.bc [... lots of .bc files ...]
error: can't create module summary index for buffer: Invalid summary version 8. Version should be in the range [1-7].
LLVM ERROR: ThinLink didn't create an index

This is because the .bc files are produced by /usr/bin/clang, which is clang 10.0.0 in the clang1000-import branch, while the llvm-lto command line uses the executable from the llvm90 port.

The bitcode is not backwards compatible, so the easiest solution is probably to make the port also *compile* with clang90, similar to what e.g. firefox and other ports do.

Alternatively, we could see if a llvm100 port becomes available, and use the llvm-lto tool from that?
Comment 1 Dimitry Andric freebsd_committer 2020-02-25 19:08:28 UTC
Created attachment 211936 [details]
Ensure postgresl-server ports use clang90

Here is a patch that appears to work, for me at least.  It sets CC, CPP and CXX to the executables from the llvm90 port, and also puts CLANG=${CC} into the configure environment.  The CLANG variable is specifically used by the postgresql Makefiles to produce bitcode.
Comment 2 Palle Girgensohn freebsd_committer 2020-02-26 23:16:50 UTC
Nice, I'll check it out. It should only be needed when the LLVM option is on.
Comment 3 O. Hartmann 2020-05-06 15:52:04 UTC
It seems, this error is still present when building ports databases/postgresql12-server and databases/postgresql11-server with poudriere (haven't taken the make-road yet):

[...]
=>> Building databases/postgresql12-server
build started at Wed May  6 15:06:14 UTC 2020
port directory: /usr/ports/databases/postgresql12-server
package name: postgresql12-server-12.2_2
building for: FreeBSD myhost.gdr 12.1-STABLE FreeBSD 12.1-STABLE 1201516 amd64
maintained by: pgsql@FreeBSD.org
Makefile ident:      $FreeBSD: head/databases/postgresql12-server/Makefile 532707 2020-04-23 20:14:22Z jbeich $
Poudriere version: 3.3.4
Host OSVERSION: 1300093
Jail OSVERSION: 1201516
Job Id: 02

---Begin Environment---
SHELL=/bin/csh
OSVERSION=1201516
UNAME_v=FreeBSD 12.1-STABLE 1201516
UNAME_r=12.1-STABLE
BLOCKSIZE=K
MAIL=/var/mail/root
STATUS=1
HOME=/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
LOCALBASE=/usr/local
USER=root
LIBEXECPREFIX=/usr/local/libexec/poudriere
POUDRIERE_VERSION=3.3.4
MAKEOBJDIRPREFIX=/pool/sources/12-STABLE/obj/
MASTERMNT=/pool/poudriere/data/.m/12-amd64-head-default/ref
POUDRIERE_BUILD_TYPE=bulk
PACKAGE_BUILDING=yes
SAVED_TERM=screen
PWD=/pool/poudriere/data/.m/12-amd64-head-default/ref/.p/pool
P_PORTS_FEATURES=FLAVORS SELECTED_OPTIONS
MASTERNAME=12-amd64-head-default
SCRIPTPREFIX=/usr/local/share/poudriere
OLDPWD=/pool/poudriere/data/.m/12-amd64-head-default/ref/.p
SCRIPTPATH=/usr/local/share/poudriere/bulk.sh
POUDRIEREPATH=/usr/local/bin/poudriere
---End Environment---

---Begin Poudriere Port Flags/Env---
PORT_FLAGS=
PKGENV=
FLAVOR=
DEPENDS_ARGS=
MAKE_ARGS=
---End Poudriere Port Flags/Env---

---Begin OPTIONS List---
===> The following configuration options are available for postgresql12-server-12.2_2:
     DEBUG=off: Build with debugging support
     DOCS=on: Build and/or install documentation
     DTRACE=off: Build with DTrace probes
     GSSAPI=on: Build with GSSAPI support
     INTDATE=on: Builds with 64-bit date/time type
     LDAP=on: Build with LDAP authentication support
     LLVM=on: Build with support for JIT-compiling expressions
     NLS=on: Use internationalized messages
     OPTIMIZED_CFLAGS=on: Builds with compiler optimizations (-O3)
     PAM=on: Build with PAM Support
     SSL=on: Build with OpenSSL support
     TZDATA=on: Use internal timezone database
     XML=on: Build with XML data type
===> Use 'make config' to modify these settings
---End OPTIONS List---



[...]
error: can't create module summary index for buffer: Invalid summary version 8. Version should be in the range [1-7].
LLVM ERROR: ThinLink didn't create an index
gmake[1]: *** [Makefile:219: install-postgres-bitcode] Error 1
gmake[1]: Leaving directory '/wrkdirs/usr/ports/databases/postgresql12-server/work/postgresql-12.2/src/backend'
gmake: *** [../../src/Makefile.global:819: install-strip] Error 2
*** Error code 2

Stop.
make: stopped in /usr/ports/databases/postgresql12-server
=>> Cleaning up wrkdir
===>  Cleaning for postgresql12-server-12.2_2
build of databases/postgresql12-server | postgresql12-server-12.2_2 ended at Wed May  6 15:22:57 UTC 2020
build time: 00:16:43
!!! build failure encountered !!!
[...]
Comment 4 Palle Girgensohn freebsd_committer 2020-05-17 20:24:57 UTC
So, we should probably use a llvm that has the same (or possibly newer?) version than the clang used.

There is an LLVM10 now, so I'm thinking something like

.if ${CLANG_VERSION} > ${DEFAULT_LLMV_VERSION}
DEFAULT_LLVM_VERSION=${CLANG_VERSION}
.endif

but so far this is pseudo code because I have not found the clang version in any easily accessible variable. I'll just have to dig deeper I guess...
Comment 5 Franco Ricci 2020-05-28 11:18:20 UTC
With FreeBSD 12.1, adding

DEFAULT_VERSIONS+=llvm=10

to make.conf

PostgreSQL12 build successfully