PostgreSQL 12 build issues on Solaris 11.4

Hello,

With the official llvm/clang release for Solaris 11.4 I tried to build PostgreSQL 12 with JIT enabled. JIT uses LLVM. However, the build fails with the following error :

gmake[2] : on entre dans le répertoire « /tmp/build/pg12/postgresql-12.0/src/backend/jit/llvm »
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -march=native -mtune=native -std=c++11 -fno-rtti -fPIC -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -I/appli/stig/llvm/clang+llvm-9.0.0-amd64-pc-solaris2.11/include -I../../../../src/include -I/usr/include/libxml2 -c -o llvmjit_inline.o llvmjit_inline.cpp
Dans le fichier inclus depuis /usr/include/sys/ucontext.h:14,
depuis /usr/include/sys/signal.h:197,
depuis /usr/include/sys/procset.h:17,
depuis /usr/include/sys/wait.h:22,
depuis /usr/include/stdlib.h:16,
depuis /usr/gcc/9/include/c++/9.1.0/cstdlib:75,
depuis /usr/gcc/9/include/c++/9.1.0/stdlib.h:36,
depuis ../../../../src/include/c.h:60,
depuis ../../../../src/include/postgres.h:46,
depuis llvmjit_inline.cpp:24:
/appli/stig/llvm/clang+llvm-9.0.0-amd64-pc-solaris2.11/include/llvm/IR/DebugInfoMetadata.h:493:45: erreur: expected « , » or « ... » before numeric constant
493 | Optional<ChecksumInfo<MDString *>> CS, Optional<MDString *> Src,
> ^~

I have encountered this issue quite often on Solaris as CS is defined in a system header included by stdlib.h :

$ gegrep '[[:space:]]CS[[:space:]]' /usr/include/sys/regset.h
#define CS 15

I can see a new regset clean of this define is provided in include/llvm/Support/Solaris/sys/regset.h. How this header should be included ?

Thanks.

-- Eric

avertissement.txt (1.05 KB)

+CC Kamil who might know the answer.

Hi Eric,

Hello,

With the official llvm/clang release for Solaris 11.4 I tried to build PostgreSQL 12 with JIT enabled. JIT uses LLVM. However, the build fails with the following error :

gmake[2] : on entre dans le répertoire « /tmp/build/pg12/postgresql-12.0/src/backend/jit/llvm »
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -march=native -mtune=native -std=c++11 -fno-rtti -fPIC -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -I/appli/stig/llvm/clang+llvm-9.0.0-amd64-pc-solaris2.11/include -I../../../../src/include -I/usr/include/libxml2 -c -o llvmjit_inline.o llvmjit_inline.cpp
Dans le fichier inclus depuis /usr/include/sys/ucontext.h:14,
                 depuis /usr/include/sys/signal.h:197,
                 depuis /usr/include/sys/procset.h:17,
                 depuis /usr/include/sys/wait.h:22,
                 depuis /usr/include/stdlib.h:16,
                 depuis /usr/gcc/9/include/c++/9.1.0/cstdlib:75,
                 depuis /usr/gcc/9/include/c++/9.1.0/stdlib.h:36,
                 depuis ../../../../src/include/c.h:60,
                 depuis ../../../../src/include/postgres.h:46,
                 depuis llvmjit_inline.cpp:24:
/appli/stig/llvm/clang+llvm-9.0.0-amd64-pc-solaris2.11/include/llvm/IR/DebugInfoMetadata.h:493:45: erreur: expected « , » or « ... » before numeric constant
  493 | Optional<ChecksumInfo<MDString *>> CS, Optional<MDString *> Src,
      > ^~

I have encountered this issue quite often on Solaris as CS is defined in a system header included by stdlib.h :

$ gegrep '[[:space:]]CS[[:space:]]' /usr/include/sys/regset.h
#define CS 15

I can see a new regset clean of this define is provided in include/llvm/Support/Solaris/sys/regset.h. How this header should be included ?

This header probably isn't intended to be included.

I't referred only in llvm/CMakeLists.txt:
   # special hack for Solaris to handle crazy system sys/regset.h
   include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")

And it's guarded by LLVM_SUPPORT_SOLARIS_SYS_REGSET_H.

SunOS defines preprocessor symbols with register names that conflict
with the source code in LLVM.

One approach to handle this problem was upstreamed to LLVM. Another one
lives in pkgsrc and is maintained by Illumos community.

Personally, I am not a user of this OS so cannot help myself. I presume
that getting pkgsrc and interacting with the Illumos community, in case
of build issues, is the easiest approach.