Bug 244403 - databases/postgresql11-server: Fix build with clang 10.0.0
Summary: databases/postgresql11-server: Fix build with clang 10.0.0
Status: Closed FIXED
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:
: 247080 249933 (view as bug list)
Depends on:
Blocks: 244251
  Show dependency treegraph
 
Reported: 2020-02-25 18:02 UTC by Dimitry Andric
Modified: 2020-09-30 21:07 UTC (History)
12 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
use same version for llvm as for clang (941 bytes, patch)
2020-09-26 10:30 UTC, Palle Girgensohn
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
Comment 6 shrdlu19 2020-07-20 06:36:18 UTC
I got same problem when building ports databases/postgresql12-server and databases/postgresql11-server with poudriere  for FreeBSD 11.4

However, Poudriere successfully builds these ports for FreeBSD 11.3 and 12.1...

=>> Building databases/postgresql11-server
build started at Mon Jul 20 10:18:59 +04 2020
port directory: /usr/ports/databases/postgresql11-server
package name: postgresql11-server-11.8_2
building for: FreeBSD FreeBSD:11:4:amd64-default-daily-job-01 11.4-RELEASE-p1 FreeBSD 11.4-RELEASE-p1 amd64
maintained by: pgsql@FreeBSD.org
Makefile ident:      $FreeBSD: head/databases/postgresql11-server/Makefile 535676 2020-05-17 20:37:04Z girgen $
Poudriere version: 3.3.4
Host OSVERSION: 1201000
Jail OSVERSION: 1104001
Job Id: 01

---Begin Environment---
SHELL=/bin/csh
OSVERSION=1104001
UNAME_v=FreeBSD 11.4-RELEASE-p1
UNAME_r=11.4-RELEASE-p1
BLOCKSIZE=K
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
MASTERMNT=/poudriere/data/.m/FreeBSD_11_4_amd64-default-daily/ref
POUDRIERE_BUILD_TYPE=bulk
PACKAGE_BUILDING=yes
SAVED_TERM=xterm
GID=0
UID=0
PWD=/poudriere/data/.m/FreeBSD_11_4_amd64-default-daily/ref/.p/pool
P_PORTS_FEATURES=FLAVORS SELECTED_OPTIONS
MASTERNAME=FreeBSD:11:4:amd64-default-daily
SCRIPTPREFIX=/usr/local/share/poudriere
OLDPWD=/poudriere/data/.m/FreeBSD_11_4_amd64-default-daily/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 postgresql11-server-11.8_2:
     DEBUG=off: Build with debugging support
     DOCS=on: Build and/or install documentation
     DTRACE=off: Build with DTrace probes
     GSSAPI=off: 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=off: Builds with compiler optimizations (-O3)
     PAM=off: Build with PAM Support
     SSL=on: Build with OpenSSL support
     TZDATA=off: Use internal timezone database
     XML=off: Build with XML data type
===> Use 'make config' to modify these settings
---End OPTIONS List---

--MAINTAINER--
pgsql@FreeBSD.org
--End MAINTAINER--

--CONFIGURE_ARGS--
--with-libraries=/usr/local/lib  --with-includes=/usr/local/include  --enable-thread-safety --with-icu --disable-debug --with-ldap --enable-nls --without-pam --with-openssl --with-system-tzdata=/usr/share/zoneinfo --without-libxml --with-llvm --without-gssapi --prefix=/usr/local ${_LATE_CONFIGURE_ARGS}
--End CONFIGURE_ARGS--

--CONFIGURE_ENV--
INCLUDES="-I/usr/local/include"  PTHREAD_LIBS="-lpthread"  LDFLAGS_SL="" PATH=/usr/local/bin:/wrkdirs/usr/ports/databases/postgresql11-server/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin LLVM_CONFIG=/usr/local/bin/llvm-config90 MAKE=gmake PKG_CONFIG=pkgconf XDG_DATA_HOME=/wrkdirs/usr/ports/databases/postgresql11-server/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/postgresql11-server/work  HOME=/wrkdirs/usr/ports/databases/postgresql11-server/work TMPDIR="/tmp" SHELL=/bin/sh CONFIG_SHELL=/bin/sh CONFIG_SITE=/usr/ports/Templates/config.site lt_cv_sys_max_cmd_len=262144
--End CONFIGURE_ENV--

--MAKE_ENV--
MAKELEVEL=0 PATH=/usr/local/bin:/wrkdirs/usr/ports/databases/postgresql11-server/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin OPENSSLBASE=/usr OPENSSLDIR=/etc/ssl OPENSSLINC=/usr/include OPENSSLLIB=/usr/lib XDG_DATA_HOME=/wrkdirs/usr/ports/databases/postgresql11-server/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/postgresql11-server/work  HOME=/wrkdirs/usr/ports/databases/postgresql11-server/work TMPDIR="/tmp" NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe  -fstack-protector-strong -DLDAP_DEPRECATED -fno-strict-aliasing "  CPP="cpp" CPPFLAGS="-I/usr/local/include"  LDFLAGS=" -L/usr/local/lib -lpthread -L/usr/local/lib  -fstack-protector-strong " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -DLDAP_DEPRECATED -fno-strict-aliasing  "  MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"
--End MAKE_ENV--

--PLIST_SUB--
PG_USER=postgres  PG_GROUP=postgres PORTDOCS="" DEBUG="@comment " NO_DEBUG="" DOCS="" NO_DOCS="@comment " DTRACE="@comment " NO_DTRACE="" GSSAPI="@comment " NO_GSSAPI="" INTDATE="" NO_INTDATE="@comment " LDAP="" NO_LDAP="@comment " LLVM="" NO_LLVM="@comment " NLS="" NO_NLS="@comment " OPTIMIZED_CFLAGS="@comment " NO_OPTIMIZED_CFLAGS="" PAM="@comment " NO_PAM="" SSL="" NO_SSL="@comment " TZDATA="@comment " NO_TZDATA="" XML="@comment " NO_XML="" LLVM="" GSSAPI="@comment " SSL="" OSREL=11.4 PREFIX=%D LOCALBASE=/usr/local  RESETPREFIX=/usr/local LIB32DIR=lib DOCSDIR="share/doc/postgresql"  EXAMPLESDIR="share/examples/postgresql"  DATADIR="share/postgresql"  WWWDIR="www/postgresql"  ETCDIR="etc/postgresql"
--End PLIST_SUB--

--SUB_LIST--
PG_GROUP=postgres  PG_USER=postgres  PG_UID=770 DEBUG="@comment " NO_DEBUG="" DOCS="" NO_DOCS="@comment " DTRACE="@comment " NO_DTRACE="" GSSAPI="@comment " NO_GSSAPI="" INTDATE="" NO_INTDATE="@comment " LDAP="" NO_LDAP="@comment " LLVM="" NO_LLVM="@comment " NLS="" NO_NLS="@comment " OPTIMIZED_CFLAGS="@comment " NO_OPTIMIZED_CFLAGS="" PAM="@comment " NO_PAM="" SSL="" NO_SSL="@comment " TZDATA="@comment " NO_TZDATA="" XML="@comment " NO_XML="" PREFIX=/usr/local LOCALBASE=/usr/local  DATADIR=/usr/local/share/postgresql DOCSDIR=/usr/local/share/doc/postgresql EXAMPLESDIR=/usr/local/share/examples/postgresql  WWWDIR=/usr/local/www/postgresql ETCDIR=/usr/local/etc/postgresql
--End SUB_LIST--

---Begin make.conf---
USE_PACKAGE_DEPENDS=yes
BATCH=yes
WRKDIRPREFIX=/wrkdirs
PORTSDIR=/usr/ports
PACKAGES=/packages
DISTDIR=/distfiles
FORCE_PACKAGE=yes
PACKAGE_BUILDING=yes
PACKAGE_BUILDING_FLAVORS=yes
#### /usr/local/etc/poudriere.d/FreeBSD:11:4:amd64-default-make.conf ####
DEFAULT_VERSIONS+= php=7.3
DEFAULT_VERSIONS+= pgsql=11
DEFAULT_VERSIONS+= samba=4.10
DEFAULT_VERSIONS+= python=3.7 python2=2.7 python3=3.7
OPTIONS_UNSET+=    X11 GUI CUPS FONTCONFIG MYSQL WAYLAND
OPTIONS_SET+=      ICONV NLS
LICENSES_ACCEPTED+= PDFlib

#### /usr/ports/Mk/Scripts/ports_env.sh ####
_CCVERSION_921dbbb2=FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b) Target: x86_64-unknown-freebsd11.4 Thread model: posix InstalledDir: /usr/bin
_ALTCCVERSION_921dbbb2=none
_CXXINTERNAL_acaad9ca=FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b) Target: x86_64-unknown-freebsd11.4 Thread model: posix InstalledDir: /usr/bin "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "--hash-style=both" "--enable-new-dtags" "-o" "a.out" "/usr/lib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/dev/null" "-lc++" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/crtend.o" "/usr/lib/crtn.o"
CC_OUTPUT_921dbbb2_58173849=yes
CC_OUTPUT_921dbbb2_9bdba57c=yes
CC_OUTPUT_921dbbb2_6a4fe7f5=yes
CC_OUTPUT_921dbbb2_6bcac02b=yes
CC_OUTPUT_921dbbb2_67d20829=yes
CC_OUTPUT_921dbbb2_bfa62e83=yes
CC_OUTPUT_921dbbb2_f0b4d593=yes
CC_OUTPUT_921dbbb2_308abb44=yes
CC_OUTPUT_921dbbb2_f00456e5=yes
CC_OUTPUT_921dbbb2_65ad290d=yes
CC_OUTPUT_921dbbb2_f2776b26=yes
CC_OUTPUT_921dbbb2_b2657cc3=yes
CC_OUTPUT_921dbbb2_380987f7=yes
CC_OUTPUT_921dbbb2_160933ec=yes
CC_OUTPUT_921dbbb2_fb62803b=yes
_OBJC_CCVERSION_921dbbb2=FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b) Target: x86_64-unknown-freebsd11.4 Thread model: posix InstalledDir: /usr/bin
_OBJC_ALTCCVERSION_921dbbb2=none
ARCH=amd64
OPSYS=FreeBSD
_OSRELEASE=11.4-RELEASE-p1
OSREL=11.4
OSVERSION=1104001
PYTHONBASE=/usr/local
HAVE_COMPAT_IA32_KERN=YES
_SMP_CPUS=12
CONFIGURE_MAX_CMD_LEN=262144
HAVE_PORTS_ENV=1
#### Misc Poudriere ####
DISABLE_MAKE_JOBS=poudriere
---End make.conf---
--Resource limits--
cpu time               (seconds, -t)  unlimited
file size           (512-blocks, -f)  unlimited
data seg size           (kbytes, -d)  33554432
stack size              (kbytes, -s)  524288
core file size      (512-blocks, -c)  unlimited
max memory size         (kbytes, -m)  unlimited
locked memory           (kbytes, -l)  unlimited
max user processes              (-u)  19558
open files                      (-n)  1024
virtual mem size        (kbytes, -v)  unlimited
swap limit              (kbytes, -w)  unlimited
socket buffer size       (bytes, -b)  unlimited
pseudo-terminals                (-p)  unlimited
kqueues                         (-k)  unlimited
umtx shared locks               (-o)  unlimited
--End resource limits--

...

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:220: install-postgres-bitcode] Error 1
gmake[1]: Leaving directory '/wrkdirs/usr/ports/databases/postgresql11-server/work/postgresql-11.8/src/backend'
gmake: *** [../../src/Makefile.global:806: install-strip] Error 2
*** Error code 2

Stop.
make: stopped in /usr/ports/databases/postgresql11-server
=>> Cleaning up wrkdir
===>  Cleaning for postgresql11-server-11.8_2
build of databases/postgresql11-server | postgresql11-server-11.8_2 ended at Mon Jul 20 10:25:03 +04 2020
build time: 00:06:04
!!! build failure encountered !!!

=>> Building databases/postgresql12-server
build started at Mon Jul 20 10:18:59 +04 2020
port directory: /usr/ports/databases/postgresql12-server
package name: postgresql12-server-12.3
building for: FreeBSD FreeBSD:11:4:amd64-default-daily-job-02 11.4-RELEASE-p1 FreeBSD 11.4-RELEASE-p1 amd64
maintained by: pgsql@FreeBSD.org
Makefile ident:      $FreeBSD: head/databases/postgresql12-server/Makefile 535676 2020-05-17 20:37:04Z girgen $
Poudriere version: 3.3.4
Host OSVERSION: 1201000
Jail OSVERSION: 1104001
Job Id: 02

---Begin Environment---
SHELL=/bin/csh
OSVERSION=1104001
UNAME_v=FreeBSD 11.4-RELEASE-p1
UNAME_r=11.4-RELEASE-p1
BLOCKSIZE=K
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
MASTERMNT=/poudriere/data/.m/FreeBSD_11_4_amd64-default-daily/ref
POUDRIERE_BUILD_TYPE=bulk
PACKAGE_BUILDING=yes
SAVED_TERM=xterm
GID=0
UID=0
PWD=/poudriere/data/.m/FreeBSD_11_4_amd64-default-daily/ref/.p/pool
P_PORTS_FEATURES=FLAVORS SELECTED_OPTIONS
MASTERNAME=FreeBSD:11:4:amd64-default-daily
SCRIPTPREFIX=/usr/local/share/poudriere
OLDPWD=/poudriere/data/.m/FreeBSD_11_4_amd64-default-daily/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.3:
     DEBUG=off: Build with debugging support
     DOCS=on: Build and/or install documentation
     DTRACE=off: Build with DTrace probes
     GSSAPI=off: 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=off: Builds with compiler optimizations (-O3)
     PAM=off: Build with PAM Support
     SSL=on: Build with OpenSSL support
     TZDATA=off: Use internal timezone database
     XML=off: Build with XML data type
===> Use 'make config' to modify these settings
---End OPTIONS List---

--MAINTAINER--
pgsql@FreeBSD.org
--End MAINTAINER--

--CONFIGURE_ARGS--
--with-libraries=/usr/local/lib  --with-includes=/usr/local/include  --enable-thread-safety --with-icu --disable-debug --with-ldap --enable-nls --without-pam --with-openssl --with-system-tzdata=/usr/share/zoneinfo --without-libxml --with-llvm --without-gssapi --prefix=/usr/local ${_LATE_CONFIGURE_ARGS}
--End CONFIGURE_ARGS--

--CONFIGURE_ENV--
INCLUDES="-I/usr/local/include"  PTHREAD_LIBS="-lpthread"  LDFLAGS_SL="" PATH=/usr/local/bin:/wrkdirs/usr/ports/databases/postgresql12-server/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin LLVM_CONFIG=/usr/local/bin/llvm-config90 MAKE=gmake PKG_CONFIG=pkgconf XDG_DATA_HOME=/wrkdirs/usr/ports/databases/postgresql12-server/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/postgresql12-server/work  HOME=/wrkdirs/usr/ports/databases/postgresql12-server/work TMPDIR="/tmp" SHELL=/bin/sh CONFIG_SHELL=/bin/sh CONFIG_SITE=/usr/ports/Templates/config.site lt_cv_sys_max_cmd_len=262144
--End CONFIGURE_ENV--

--MAKE_ENV--
MAKELEVEL=0 PATH=/usr/local/bin:/wrkdirs/usr/ports/databases/postgresql12-server/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin OPENSSLBASE=/usr OPENSSLDIR=/etc/ssl OPENSSLINC=/usr/include OPENSSLLIB=/usr/lib XDG_DATA_HOME=/wrkdirs/usr/ports/databases/postgresql12-server/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/postgresql12-server/work  HOME=/wrkdirs/usr/ports/databases/postgresql12-server/work TMPDIR="/tmp" NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe  -fstack-protector-strong -DLDAP_DEPRECATED -fno-strict-aliasing "  CPP="cpp" CPPFLAGS="-I/usr/local/include"  LDFLAGS=" -L/usr/local/lib -lpthread -L/usr/local/lib  -fstack-protector-strong " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -DLDAP_DEPRECATED -fno-strict-aliasing  "  MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"
--End MAKE_ENV--

--PLIST_SUB--
PG_USER=postgres  PG_GROUP=postgres PORTDOCS="" DEBUG="@comment " NO_DEBUG="" DOCS="" NO_DOCS="@comment " DTRACE="@comment " NO_DTRACE="" GSSAPI="@comment " NO_GSSAPI="" INTDATE="" NO_INTDATE="@comment " LDAP="" NO_LDAP="@comment " LLVM="" NO_LLVM="@comment " NLS="" NO_NLS="@comment " OPTIMIZED_CFLAGS="@comment " NO_OPTIMIZED_CFLAGS="" PAM="@comment " NO_PAM="" SSL="" NO_SSL="@comment " TZDATA="@comment " NO_TZDATA="" XML="@comment " NO_XML="" LLVM="" GSSAPI="@comment " SSL="" OSREL=11.4 PREFIX=%D LOCALBASE=/usr/local  RESETPREFIX=/usr/local LIB32DIR=lib DOCSDIR="share/doc/postgresql"  EXAMPLESDIR="share/examples/postgresql"  DATADIR="share/postgresql"  WWWDIR="www/postgresql"  ETCDIR="etc/postgresql"
--End PLIST_SUB--

--SUB_LIST--
PG_GROUP=postgres  PG_USER=postgres  PG_UID=770 DEBUG="@comment " NO_DEBUG="" DOCS="" NO_DOCS="@comment " DTRACE="@comment " NO_DTRACE="" GSSAPI="@comment " NO_GSSAPI="" INTDATE="" NO_INTDATE="@comment " LDAP="" NO_LDAP="@comment " LLVM="" NO_LLVM="@comment " NLS="" NO_NLS="@comment " OPTIMIZED_CFLAGS="@comment " NO_OPTIMIZED_CFLAGS="" PAM="@comment " NO_PAM="" SSL="" NO_SSL="@comment " TZDATA="@comment " NO_TZDATA="" XML="@comment " NO_XML="" PREFIX=/usr/local LOCALBASE=/usr/local  DATADIR=/usr/local/share/postgresql DOCSDIR=/usr/local/share/doc/postgresql EXAMPLESDIR=/usr/local/share/examples/postgresql  WWWDIR=/usr/local/www/postgresql ETCDIR=/usr/local/etc/postgresql
--End SUB_LIST--

---Begin make.conf---
USE_PACKAGE_DEPENDS=yes
BATCH=yes
WRKDIRPREFIX=/wrkdirs
PORTSDIR=/usr/ports
PACKAGES=/packages
DISTDIR=/distfiles
FORCE_PACKAGE=yes
PACKAGE_BUILDING=yes
PACKAGE_BUILDING_FLAVORS=yes
#### /usr/local/etc/poudriere.d/FreeBSD:11:4:amd64-default-make.conf ####
DEFAULT_VERSIONS+= php=7.3
DEFAULT_VERSIONS+= pgsql=11
DEFAULT_VERSIONS+= samba=4.10
DEFAULT_VERSIONS+= python=3.7 python2=2.7 python3=3.7
OPTIONS_UNSET+=    X11 GUI CUPS FONTCONFIG MYSQL WAYLAND
OPTIONS_SET+=      ICONV NLS
LICENSES_ACCEPTED+= PDFlib

#### /usr/ports/Mk/Scripts/ports_env.sh ####
_CCVERSION_921dbbb2=FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b) Target: x86_64-unknown-freebsd11.4 Thread model: posix InstalledDir: /usr/bin
_ALTCCVERSION_921dbbb2=none
_CXXINTERNAL_acaad9ca=FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b) Target: x86_64-unknown-freebsd11.4 Thread model: posix InstalledDir: /usr/bin "/usr/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld-elf.so.1" "--hash-style=both" "--enable-new-dtags" "-o" "a.out" "/usr/lib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/dev/null" "-lc++" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/crtend.o" "/usr/lib/crtn.o"
CC_OUTPUT_921dbbb2_58173849=yes
CC_OUTPUT_921dbbb2_9bdba57c=yes
CC_OUTPUT_921dbbb2_6a4fe7f5=yes
CC_OUTPUT_921dbbb2_6bcac02b=yes
CC_OUTPUT_921dbbb2_67d20829=yes
CC_OUTPUT_921dbbb2_bfa62e83=yes
CC_OUTPUT_921dbbb2_f0b4d593=yes
CC_OUTPUT_921dbbb2_308abb44=yes
CC_OUTPUT_921dbbb2_f00456e5=yes
CC_OUTPUT_921dbbb2_65ad290d=yes
CC_OUTPUT_921dbbb2_f2776b26=yes
CC_OUTPUT_921dbbb2_b2657cc3=yes
CC_OUTPUT_921dbbb2_380987f7=yes
CC_OUTPUT_921dbbb2_160933ec=yes
CC_OUTPUT_921dbbb2_fb62803b=yes
_OBJC_CCVERSION_921dbbb2=FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b) Target: x86_64-unknown-freebsd11.4 Thread model: posix InstalledDir: /usr/bin
_OBJC_ALTCCVERSION_921dbbb2=none
ARCH=amd64
OPSYS=FreeBSD
_OSRELEASE=11.4-RELEASE-p1
OSREL=11.4
OSVERSION=1104001
PYTHONBASE=/usr/local
HAVE_COMPAT_IA32_KERN=YES
_SMP_CPUS=12
CONFIGURE_MAX_CMD_LEN=262144
HAVE_PORTS_ENV=1
#### Misc Poudriere ####
DISABLE_MAKE_JOBS=poudriere
---End make.conf---
--Resource limits--
cpu time               (seconds, -t)  unlimited
file size           (512-blocks, -f)  unlimited
data seg size           (kbytes, -d)  33554432
stack size              (kbytes, -s)  524288
core file size      (512-blocks, -c)  unlimited
max memory size         (kbytes, -m)  unlimited
locked memory           (kbytes, -l)  unlimited
max user processes              (-u)  19558
open files                      (-n)  1024
virtual mem size        (kbytes, -v)  unlimited
swap limit              (kbytes, -w)  unlimited
socket buffer size       (bytes, -b)  unlimited
pseudo-terminals                (-p)  unlimited
kqueues                         (-k)  unlimited
umtx shared locks               (-o)  unlimited
--End resource limits--

...

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.3/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.3
build of databases/postgresql12-server | postgresql12-server-12.3 ended at Mon Jul 20 10:25:23 +04 2020
build time: 00:06:24
!!! build failure encountered !!!
Comment 7 gergely.czuczy 2020-07-23 15:33:52 UTC
I'm also getting this issue when building psql12.
System is 12.1-STABLE r363367 amd64
ports checked out a couple of days ago

When turning off LLVM support the port builds, but we're not getting the feature.
Comment 8 Terry Kennedy 2020-08-01 00:21:58 UTC
Subscribing and adding a "me too" for this problem.
Comment 9 Patrick McMunn 2020-09-12 17:00:35 UTC
This issue also affects LLVM/Clang 11 on 13-CURRENT
Comment 10 Patrick McMunn 2020-09-12 17:28:11 UTC
I think I found an upstream bug in LLVM/Clang for this issue. It has been fixed upstream (assuming this is the same issue), but maybe FreeBSD hasn't incorporated the backported patch? See https://bugs.llvm.org/show_bug.cgi?id=45384
Comment 11 Dimitry Andric freebsd_committer 2020-09-12 19:22:43 UTC
(In reply to Patrick McMunn from comment #10)
Eh, why do you think that upstream bug report has anything to do with the error people are getting?

This bug is about different versions of llvm bitcode files not being completely compatible with each other, e.g. if your .bc files are produced by clang 10, you cannot compile them with clang <= 9. Similarly, .bc files produced by clang 11 cannot be compiled with clang <= 10.

The problem lies in the port itself, which appears to force the usage of an llvm port, but only for *part* of its build. The first "half" seems to build with the system compiler, the second "half" with a specific llvm port. Unless the versions match, this will not work.
Comment 12 Patrick McMunn 2020-09-13 04:06:44 UTC
I could be wrong. But the LLVM/Clang bug I mentioned above was referenced in this Ubuntu bug report ( https://bugs.launchpad.net/ubuntu/+source/postgresql-12/+bug/1867173 ) which seemed to be the same as this FreeBSD bug. Anyway, I didn't mean to toss out a red herring if it's a different issue.
Comment 13 O. Hartmann 2020-09-26 05:42:26 UTC
*** Bug 247080 has been marked as a duplicate of this bug. ***
Comment 14 Dimitry Andric freebsd_committer 2020-09-26 08:00:10 UTC
Ok, can we simply apply my patch now, since that works? Similar for the postgresql12 port, probably. Otherwise people will keep bumping into this non-issue.
Comment 15 Palle Girgensohn freebsd_committer 2020-09-26 10:10:51 UTC
(In reply to Dimitry Andric from comment #14)

Well, in that case the patch needs to depend on the clang90 port as well.

Wouldn't it be better to make sure that the version of llvm matches the version of clang?
Comment 16 Palle Girgensohn freebsd_committer 2020-09-26 10:27:37 UTC
Would it make sense keeping the same version for clang and llvm? Like this?

Index: Makefile
===================================================================
--- Makefile	(revision 550053)
+++ Makefile	(working copy)
@@ -181,10 +181,10 @@
 
 .if ${DISTVERSION:C/([0-9]*).*/\1/} >= 11
 .  if defined(SERVER_ONLY) && ${PORT_OPTIONS:MLLVM}
-BUILD_DEPENDS+=		llvm${LLVM_DEFAULT}>0:devel/llvm${LLVM_DEFAULT}
-BUILD_DEPENDS+=		llvm-config${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
-RUN_DEPENDS+=		llvm-config${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
-CONFIGURE_ENV+=		LLVM_CONFIG=${LOCALBASE}/bin/llvm-config${LLVM_DEFAULT}
+BUILD_DEPENDS+=		llvm${COMPILER_VERSION}>0:devel/llvm${COMPILER_VERSION}
+BUILD_DEPENDS+=		llvm-config${COMPILER_VERSION}:devel/llvm${COMPILER_VERSION}
+RUN_DEPENDS+=		llvm-config${COMPILER_VERSION}:devel/llvm${COMPILER_VERSION}
+CONFIGURE_ENV+=		LLVM_CONFIG=${LOCALBASE}/bin/llvm-config${COMPILER_VERSION}
 CONFIGURE_ARGS+=	--with-llvm
 PLIST_SUB+=		LLVM=""
 INSTALL_DIRS+=		src/backend/jit/llvm
Comment 17 Palle Girgensohn freebsd_committer 2020-09-26 10:30:41 UTC
Created attachment 218316 [details]
use same version for llvm as for clang

Sorry for previous post, the patch was unreadable.

This would downgrade llvm from 9.0 to 8.0 for FreeBSD-12.1 so maybe it's not such a good idea?
Comment 18 commit-hook freebsd_committer 2020-09-27 20:18:04 UTC
A commit references this bug:

Author: girgen
Date: Sun Sep 27 20:17:58 UTC 2020
New revision: 550339
URL: https://svnweb.freebsd.org/changeset/ports/550339

Log:
  Fix building with LLVM

  Fix a plist issue [1].

  Make sure the LLVM options are correctly handled. Setting the OPTIONS_DEFAULT
  conditionally based on wheather the default compiler is cland doesn't work
  properly, it is always set even if you deselect it. Just setting it per default
  seems to work better.

  Attempt a fix for building on FreeBSD-13.0 where clang is newer than the
  default LLVM. First attempt is to use an lower version clang to match what LLVM
  has as default. [2]

  PR:	244403 [2], 249933 [2], 249875 [1]

Changes:
  head/databases/postgresql13-server/Makefile
  head/databases/postgresql13-server/pkg-plist-server
Comment 19 Palle Girgensohn freebsd_committer 2020-09-27 20:22:42 UTC
*** Bug 249933 has been marked as a duplicate of this bug. ***
Comment 20 Palle Girgensohn freebsd_committer 2020-09-27 20:23:33 UTC
Hi!

I've committed a change that makes sure clang and llvm have the samge version,  LLVM_DEFAULT.

Perhaps the opposite would preferable, i. e. setting the LLVM-version to the same version as base clang?

Please respond with your thoughts. Does the patch help for you?

Palle
Comment 21 Trond.Endrestol 2020-09-28 18:39:14 UTC
(In reply to Palle Girgensohn from comment #20)
As far as I can tell it makes no difference.
Comment 22 Trond.Endrestol 2020-09-29 04:41:51 UTC
(In reply to Trond.Endrestol from comment #21)
Oh, I'm using a snapshot of base/head stamped as 1300100 when building my packages, that might explain a thing or two.
Comment 23 commit-hook freebsd_committer 2020-09-30 20:53:14 UTC
A commit references this bug:

Author: girgen
Date: Wed Sep 30 20:52:17 UTC 2020
New revision: 550749
URL: https://svnweb.freebsd.org/changeset/ports/550749

Log:
  Try to fix build on recent FreeBSD versions where clang version > llvm default
  ports version. Fix this by depending on a higher version of llvm if such a
  version exixts, and otherwise use a clang version compatible with the latest
  llvm.

  Using llvm was previously dependant on clang being used, and this did not quite
  work for all cases due to some weird order of variables in the Makefile. The
  result was that the option set by the used was not really honored. The
  portrevision is bumped to reflect that the setting of LLVM might not have
  worked before this portrevison.

  PR:	244403

Changes:
  head/databases/postgresql11-server/Makefile
  head/databases/postgresql12-server/Makefile
  head/databases/postgresql13-server/Makefile
Comment 24 Palle Girgensohn freebsd_committer 2020-09-30 21:07:15 UTC
I don't have an environment at hand where clang 10 is default, and poudriere refuses to run such an environment on a 12.1 kernel, but I believe the latset commit fixes the build problems for you. If not, please reopen the PR.