Bug 249933

Summary: databases/postgresql13-server: Unable to build package witth LLVM enabled due to invalid summary version 8
Product: Ports & Packages Reporter: Trond Endrestøl <Trond.Endrestol>
Component: Individual Port(s)Assignee: pgsql
Status: Closed DUPLICATE    
Severity: Affects Only Me CC: Trond.Endrestol, girgen
Priority: --- Flags: bugzilla: maintainer-feedback? (pgsql)
Version: Latest   
Hardware: Any   
OS: Any   

Description Trond Endrestøl 2020-09-27 10:25:29 UTC
This happens on amd64, base/head, r365923.
Ports tree is at ports/head, r550259.

databases/postgresql13-server is configured this way:

===> The following configuration options are available for postgresql13-server-13.0_1:                                                                                                                                                                                                                                         
     DEBUG=off: Build with debugging support                                                                                                                                                                                                                                                                                   
     DOCS=on: Build and/or install documentation                                                                                                                                                                                                                                                                               
     DTRACE=on: Build with DTrace probes                                                                                                                                                                                                                                                                                       
     GSSAPI=off: Build with GSSAPI support                                                                                                                                                                                                                                                                                     
     INTDATE=on: Builds with 64-bit date/time type                                                                                                                                                                                                                                                                             
     LDAP=off: Build with LDAP authentication support                                                                                                                                                                                                                                                                          
     LLVM=on: Build with support for JIT-compiling expressions                                                                                                                                                                                                                                                                 
     NLS=off: Use internationalized messages                                                                                                                                                                                                                                                                                   
     OPTIMIZED_CFLAGS=on: Builds with compiler optimizations (-O3)                                                                                                                                                                                                                                                             
     PAM=off: Build with PAM Support                                                                                                                                                                                                                                                                                           
     SSL=on: Build with OpenSSL support                                                                                                                                                                                                                                                                                        
     TZDATA=on: Use internal timezone database                                                                                                                                                                                                                                                                                 
     XML=off: Build with XML data type

At the end of the build log:

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: *** [Makefile:222: install-postgres-bitcode] Error 1
*** Error code 2
Comment 1 Trond Endrestøl 2020-09-27 10:37:39 UTC
Apparently it's impossible to turn off the LLVM option. Despite having the LLVM option marked as UNSET in the options file, make showconfig show the LLVM option as enabled.

$ cat options
# This file is auto-generated by 'make config'.
# Options for postgresql13-server-13.0_1
_OPTIONS_READ=postgresql13-server-13.0_1
_FILE_COMPLETE_OPTIONS_LIST=DEBUG DOCS DTRACE GSSAPI INTDATE LDAP LLVM NLS OPTIMIZED_CFLAGS PAM SSL TZDATA XML
OPTIONS_FILE_UNSET+=DEBUG
OPTIONS_FILE_SET+=DOCS
OPTIONS_FILE_SET+=DTRACE
OPTIONS_FILE_UNSET+=GSSAPI
OPTIONS_FILE_SET+=INTDATE
OPTIONS_FILE_UNSET+=LDAP
OPTIONS_FILE_UNSET+=LLVM
OPTIONS_FILE_UNSET+=NLS
OPTIONS_FILE_SET+=OPTIMIZED_CFLAGS
OPTIONS_FILE_UNSET+=PAM
OPTIONS_FILE_SET+=SSL
OPTIONS_FILE_SET+=TZDATA
OPTIONS_FILE_UNSET+=XML

$ make showconfig
===> The following configuration options are available for postgresql13-server-13.0_1:                                                                                                                                                                                                                                         
     DEBUG=off: Build with debugging support                                                                                                                                                                                                                                                                                   
     DOCS=on: Build and/or install documentation                                                                                                                                                                                                                                                                               
     DTRACE=on: Build with DTrace probes                                                                                                                                                                                                                                                                                       
     GSSAPI=off: Build with GSSAPI support                                                                                                                                                                                                                                                                                     
     INTDATE=on: Builds with 64-bit date/time type                                                                                                                                                                                                                                                                             
     LDAP=off: Build with LDAP authentication support                                                                                                                                                                                                                                                                          
     LLVM=on: Build with support for JIT-compiling expressions                                                                                                                                                                                                                                                                 
     NLS=off: Use internationalized messages                                                                                                                                                                                                                                                                                   
     OPTIMIZED_CFLAGS=on: Builds with compiler optimizations (-O3)                                                                                                                                                                                                                                                             
     PAM=off: Build with PAM Support                                                                                                                                                                                                                                                                                           
     SSL=on: Build with OpenSSL support                                                                                                                                                                                                                                                                                        
     TZDATA=on: Use internal timezone database                                                                                                                                                                                                                                                                                 
     XML=off: Build with XML data type

I commented out lines 93 through 98 in the ports' Makefile to see if I can get port built this way.
Comment 2 Trond Endrestøl 2020-09-27 10:49:03 UTC
(In reply to Trond.Endrestol from comment #1)
The lLVM problem disappeared, but a new problem occurred:

===>  Building package for postgresql13-server-13.0_1
pkg-static: Unable to access file /construction/xports/databases/postgresql13-server/work/stage/usr/local/share/postgresql/timezone/posixrules:No such file or directory
*** Error code 1
Comment 3 Trond Endrestøl 2020-09-27 11:27:59 UTC
(In reply to Trond.Endrestol from comment #2)
"@commenting" out the

%%TZDATA%%%%DATADIR%%/timezone/posixrules

line in the pkg-plist-server file took care of the TZDATA problem. Finally, the package built successfully.

The LLVM problem is unique to databases/postgresql13-server as databases/postgresql12-server is unaffected.
Comment 4 Trond Endrestøl 2020-09-27 11:53:12 UTC
(In reply to Trond.Endrestol from comment #3)
I reenabled the LLVM option, lines 93 through 98, in databases/postgresql13-server/Makefile. And now both databases/postgresql12-server and databases/postgresql13-server are equally affected:

cd '/construction/xports/databases/postgresql12-server/work/stage/usr/local/lib/postgresql/bitcode' && /usr/local/llvm90/bin/llvm-lto -thinlto -thinlto-action=thinlink -o postgres.index.bc ...
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: *** [Makefile:219: install-postgres-bitcode] Error 1
*** Error code 2

Could this be a ccache induced error? I will try again without ccache being enabled.
Comment 5 Trond Endrestøl 2020-09-27 12:11:01 UTC
(In reply to Trond.Endrestol from comment #4)
No, passifying ccache by setting recache = true in ccache.conf only increased the build times and regenerated files already in the ccache. The LLVM bug persists for both 12 and 13. Does anyone else see this behaviour?
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-09-27 20:18:11 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 7 Palle Girgensohn freebsd_committer freebsd_triage 2020-09-27 20:22:42 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?

I'll set this as a duplicate of 244403. Please respond there with your thoughts. Does the patch help for you?

Palle

*** This bug has been marked as a duplicate of bug 244403 ***