MINOR: build: add aix72-gcc build TARGET and power{8,9} CPUs

As haproxy wont build on AIX 7.2 using the old "aix52" TARGET a new
TARGET was introduced which adds two special CFLAGS to prevent the
loading of AIXs xmem.h and var.h. This is done by defining the
corresponding include-guards _H_XMEM and _H_VAR. Without excluding
those headers-files the build fails because of redefinition errors:

1)
  CC      src/mux_fcgi.o
In file included from /usr/include/sys/uio.h:90,
                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/8.3.0/include-fixed/sys/socket.h:104,
                 from include/common/compat.h:32,
                 from include/common/cfgparse.h:25,
                 from src/mux_fcgi.c:13:
src/mux_fcgi.c:204:13: error: expected ':', ',', ';', '}' or '__attribute__' before '.' token
  struct ist rem_addr;
             ^~~~~~~~

2)
  CC      src/cfgparse-listen.o
In file included from include/types/arg.h:31,
                 from include/types/acl.h:29,
                 from include/types/proxy.h:41,
                 from include/proto/log.h:34,
                 from include/common/cfgparse.h:30,
                 from src/mux_h2.c:13:
include/types/vars.h:30:8: error: redefinition of 'struct var'
 struct var {
        ^~~

Futhermore, to enable multithreading via USE_THREAD, the atomic
library was added to the LDFLAGS. Finally, two new CPUs were added
to simplify the usage of power8 and power9 optimizations.

This TARGET was only tested on GCC 8.3 and may or may not work on
IBM's native C-compiler (XLC).

Should be backported to 2.1.
This commit is contained in:
Christian Lachner 2020-02-10 10:29:13 +01:00 committed by Willy Tarreau
parent c0e23aef05
commit c13223022c
2 changed files with 25 additions and 5 deletions

10
INSTALL
View File

@ -379,6 +379,7 @@ and assign it to the TARGET variable :
- openbsd for OpenBSD 5.7 and above
- aix51 for AIX 5.1
- aix52 for AIX 5.2
- aix72-gcc for AIX 7.2 (using gcc)
- cygwin for Cygwin
- haiku for Haiku
- generic for any other OS or version.
@ -391,6 +392,8 @@ one of the following choices to the CPU variable :
- i686 for intel PentiumPro, Pentium 2 and above, AMD Athlon (32 bits)
- i586 for intel Pentium, AMD K6, VIA C3.
- ultrasparc : Sun UltraSparc I/II/III/IV processor
- power8 : IBM POWER8 processor
- power9 : IBM POWER9 processor
- native : use the build machine's specific processor optimizations. Use with
extreme care, and never in virtualized environments (known to break).
- generic : any other processor or no CPU-specific optimization. (default)
@ -516,6 +519,13 @@ this is easily addressed using the "aix52" target. If you get build errors
because of strange symbols or section mismatches, simply remove -g from
DEBUG_CFLAGS.
Building on AIX 7.2 works fine using the "aix72-gcc" TARGET. It adds two
special CFLAGS to prevent the loading of AIXs xmem.h and var.h. This is done
by defining the corresponding include-guards _H_XMEM and _H_VAR. Without
excluding those header-files the build fails because of redefinition errors.
Futhermore, the atomic library is added to the LDFLAGS to allow for
multithreading via USE_THREAD.
You can easily define your own target with the GNU Makefile. Unknown targets
are processed with no default option except USE_POLL=default. So you can very
well use that property to define your own set of options. USE_POLL can even be

View File

@ -144,13 +144,13 @@ DOCDIR = $(PREFIX)/doc/haproxy
# Use TARGET=<target_name> to optimize for a specifc target OS among the
# following list (use the default "generic" if uncertain) :
# linux-glibc, linux-glibc-legacy, solaris, freebsd, openbsd, netbsd,
# cygwin, haiku, aix51, aix52, osx, generic, custom
# cygwin, haiku, aix51, aix52, aix72-gcc, osx, generic, custom
TARGET =
#### TARGET CPU
# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
# list :
# generic, native, i586, i686, ultrasparc, custom
# generic, native, i586, i686, ultrasparc, power8, power9, custom
CPU = generic
#### Architecture, used when not building for native architecture
@ -257,6 +257,8 @@ CPU_CFLAGS.native = -O2 -march=native
CPU_CFLAGS.i586 = -O2 -march=i586
CPU_CFLAGS.i686 = -O2 -march=i686
CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
CPU_CFLAGS.power8 = -O2 -mcpu=power8 -mtune=power8
CPU_CFLAGS.power9 = -O2 -mcpu=power9 -mtune=power9
CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
#### ARCH dependant flags, may be overridden by CPU flags
@ -381,7 +383,7 @@ ifeq ($(TARGET),aix51)
DEBUG_CFLAGS =
endif
# AIX 5.2 and above
# AIX 5.2
ifeq ($(TARGET),aix52)
set_target_defaults = $(call default_opts, \
USE_POLL USE_LIBCRYPT USE_OBSOLETE_LINKER)
@ -389,6 +391,14 @@ ifeq ($(TARGET),aix52)
DEBUG_CFLAGS =
endif
# AIX 7.2 and above
ifeq ($(TARGET),aix72-gcc)
set_target_defaults = $(call default_opts, \
USE_POLL USE_THREAD USE_LIBCRYPT USE_OBSOLETE_LINKER USE_GETADDRINFO)
TARGET_CFLAGS = -D_H_XMEM -D_H_VAR
TARGET_LDFLAGS = -latomic
endif
# Cygwin
ifeq ($(TARGET),cygwin)
set_target_defaults = $(call default_opts, \
@ -754,7 +764,7 @@ all:
@echo "Please choose the target among the following supported list :"
@echo
@echo " linux-glibc, linux-glibc-legacy, solaris, freebsd, openbsd, netbsd,"
@echo " cygwin, haiku, aix51, aix52, osx, generic, custom"
@echo " cygwin, haiku, aix51, aix52, aix72-gcc, osx, generic, custom"
@echo
@echo "Use \"generic\" if you don't want any optimization, \"custom\" if you"
@echo "want to precisely tweak every option, or choose the target which"
@ -832,7 +842,7 @@ help:
else \
echo "TARGET not set, you may pass 'TARGET=xxx' to set one among :";\
echo " linux-glibc, linux-glibc-legacy, solaris, freebsd, netbsd, osx,"; \
echo " openbsd, aix51, aix52, cygwin, haiku, generic, custom"; \
echo " openbsd, aix51, aix52, aix72-gcc, cygwin, haiku, generic, custom"; \
fi
$(Q)echo;echo "Enabled features for TARGET '$(TARGET)' (disable with 'USE_xxx=') :"
$(Q)set -- $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),$(opt),)); echo " $$*" | (fmt || cat) 2>/dev/null