Opened 2 years ago

Closed 2 years ago

#65699 closed defect (fixed)

haproxy fails on Rosetta: error: thread-local storage not supported for this target compilation terminated due to -Wfatal-errors; tcp_sample.c: error: storage size of 'info' isn't known

Reported by: barracuda156 Owned by: judaew (Vadym-Valdis Yudaiev)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: powerpc, rosetta, snowleopard Cc:
Port: haproxy

Description

--->  Building haproxy
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3" && /usr/bin/make -j6 -w TARGET=osx LD="/usr/bin/gcc-4.2" LDFLAGS="-L/opt/local/libexec/openssl3/lib -Wl,-headerpad_max_install_names -L/opt/local/lib -lMacportsLegacySupport" SSL_INC=/opt/local/libexec/openssl3/include SSL_LIB=/opt/local/libexec/openssl3/lib USE_LIBCRYPT=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_THREAD=1 USE_ZLIB=1 CC="/usr/bin/gcc-4.2" CXX="/usr/bin/g++-4.2" OBJC="/usr/bin/gcc-4.2" OBJCXX="/usr/bin/g++-4.2" INSTALL="/usr/bin/install -c" 
  CC      src/ev_poll.o
make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3'
  CC      src/ev_kqueue.o
  CC      src/cpuset.o
  CC      src/ssl_sample.o
  CC      src/ssl_sock.o
  CC      src/ssl_crtlist.o
  CC      src/ssl_ckch.o
In file included from src/ev_poll.c:22:
include/haproxy/clock.h:31: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
In file included from src/ev_kqueue.c:22:
include/haproxy/clock.h:31: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
make: *** [src/ev_poll.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [src/ev_kqueue.o] Error 1
In file included from include/haproxy/freq_ctr.h:28,
                 from include/haproxy/pool.h:28,
                 from include/haproxy/chunk.h:31,
                 from include/haproxy/dynbuf.h:33,
                 from include/haproxy/channel.h:27,
                 from include/haproxy/applet.h:29,
                 from src/ssl_crtlist.c:23:
include/haproxy/ticks.h:66: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
In file included from include/haproxy/fd.h:33,
                 from include/haproxy/connection.h:31,
                 from src/ssl_sample.c:27:
include/haproxy/global.h:53: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
In file included from include/haproxy/freq_ctr.h:28,
                 from include/haproxy/pool.h:28,
                 from include/haproxy/chunk.h:31,
                 from include/haproxy/dynbuf.h:33,
                 from include/haproxy/channel.h:27,
                 from include/haproxy/applet.h:29,
                 from src/ssl_sock.c:47:
include/haproxy/ticks.h:66: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
make: *** [src/ssl_crtlist.o] Error 1
make: *** [src/ssl_sock.o] Error 1
make: *** [src/ssl_sample.o] Error 1
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3" && /usr/bin/make -j6 -w TARGET=osx LD="/usr/bin/gcc-4.2" LDFLAGS="-L/opt/local/libexec/openssl3/lib -Wl,-headerpad_max_install_names -L/opt/local/lib -lMacportsLegacySupport" SSL_INC=/opt/local/libexec/openssl3/include SSL_LIB=/opt/local/libexec/openssl3/lib USE_LIBCRYPT=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_THREAD=1 USE_ZLIB=1 CC="/usr/bin/gcc-4.2" CXX="/usr/bin/g++-4.2" OBJC="/usr/bin/gcc-4.2" OBJCXX="/usr/bin/g++-4.2" INSTALL="/usr/bin/install -c" 
Exit code: 2

Change History (8)

comment:1 Changed 2 years ago by barracuda156

So note this code in portfile does not work:

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    build.args-delete   USE_THREAD=1
}

USE_THREAD=1 is NOT removed on 10.6.

UPD. This is likely the reason, in Makefile:

# Mac OS/X
ifeq ($(TARGET),osx)
  set_target_defaults = $(call default_opts, \
    USE_POLL USE_TPROXY USE_LIBCRYPT USE_THREAD USE_CPU_AFFINITY USE_KQUEUE   \
    USE_GETADDRINFO)
  EXPORT_SYMBOL  = -export_dynamic
endif
Last edited 2 years ago by barracuda156 (previous) (diff)

comment:2 Changed 2 years ago by barracuda156

Then, with gcc12 it fails later on and differently:

src/pool.c: In function 'trim_all_pools':
src/pool.c:132:49: warning: implicit declaration of function 'malloc_zone_pressure_relief' [-Wimplicit-function-declaration]
  132 |                                                 malloc_zone_pressure_relief(zone, 0);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  CC      src/tcp_sample.o
  CC      src/flt_http_comp.o
  CC      src/mux_pt.o
src/tcp_sample.c: In function 'get_tcp_info':
src/tcp_sample.c:317:25: error: storage size of 'info' isn't known
  317 |         struct tcp_info info;
      |                         ^~~~
compilation terminated due to -Wfatal-errors.
make: *** [src/tcp_sample.o] Error 1
make: *** Waiting for unfinished jobs....
At top level:
cc1: note: unrecognized command-line option '-Wno-atomic-alignment' may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option '-Wno-string-plus-int' may have been intended to silence earlier diagnostics
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3'

comment:3 Changed 2 years ago by barracuda156

Summary: haproxy fails on Rosetta: error: thread-local storage not supported for this target compilation terminated due to -Wfatal-errorshaproxy fails on Rosetta: error: thread-local storage not supported for this target compilation terminated due to -Wfatal-errors; tcp_sample.c: error: storage size of 'info' isn't known

comment:4 Changed 2 years ago by barracuda156

Also, even setting USE_THREAD=0 does nothing when build is done with gcc-4.2:

--->  Building haproxy
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3" && /usr/bin/make -j6 -w TARGET=osx USE_THREAD=0 LD="/usr/bin/gcc-4.2" LDFLAGS="-L/opt/local/libexec/openssl3/lib -Wl,-headerpad_max_install_names -L/opt/local/lib -lMacportsLegacySupport" SSL_INC=/opt/local/libexec/openssl3/include SSL_LIB=/opt/local/libexec/openssl3/lib USE_LIBCRYPT=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_ZLIB=1 CC="/usr/bin/gcc-4.2" CXX="/usr/bin/g++-4.2" OBJC="/usr/bin/gcc-4.2" OBJCXX="/usr/bin/g++-4.2" INSTALL="/usr/bin/install -c" 
  CC      src/ev_poll.o
make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_haproxy/haproxy/work/haproxy-2.6.3'
  CC      src/ev_kqueue.o
  CC      src/cpuset.o
  CC      src/ssl_sample.o
  CC      src/ssl_sock.o
  CC      src/ssl_crtlist.o
  CC      src/ssl_ckch.o
In file included from src/ev_poll.c:22:
include/haproxy/clock.h:31: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
In file included from src/ev_kqueue.c:22:
include/haproxy/clock.h:31: error: thread-local storage not supported for this target
compilation terminated due to -Wfatal-errors.
make: *** [src/ev_poll.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [src/ev_kqueue.o] Error 1

So to begin with, old gcc must be blacklisted.

comment:5 Changed 2 years ago by kencu (Ken)

if a port must use thread_local storage, and it cannot be disabled, there is a setting to allow base to choose a proper compiler.

see https://trac.macports.org/wiki/CompilerSelection for the settings to use

we don’t manually blacklist for this common issue.

malloc_zone_pressure_relief is only available in 10.7+, so that will have to be worked around some other way if possible.

See https://opensource.apple.com/source/Libc/Libc-825.26/include/malloc/malloc.h.auto.html

comment:6 in reply to:  5 Changed 2 years ago by barracuda156

Replying to kencu:

if a port must use thread_local storage, and it cannot be disabled, there is a setting to allow base to choose a proper compiler.

see https://trac.macports.org/wiki/CompilerSelection for the settings to use

we don’t manually blacklist for this common issue.

Got it, using compiler.thread_local_storage yes now.

malloc_zone_pressure_relief is only available in 10.7+, so that will have to be worked around some other way if possible.

See https://opensource.apple.com/source/Libc/Libc-825.26/include/malloc/malloc.h.auto.html

Thank you! I have just fixed TCP_INFO issue, and got to:

Undefined symbols:
  "_malloc_zone_pressure_relief", referenced from:
      _pool_gc in pool.o
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
make: *** [haproxy] Error 1

UPD. I guess we should should just make definitions conditional, like:

/* macOS has a call similar to malloc_usable_size */
#if defined(__APPLE__)
#include <AvailabilityMacros.h>
#include <malloc/malloc.h>
#define malloc_usable_size malloc_size
#if MAC_OS_X_VERSION_MIN_REQUIRED > 1060
#define HA_HAVE_MALLOC_ZONE
#endif
#define TCP_KEEPIDLE TCP_KEEPALIVE
#if MAC_OS_X_VERSION_MIN_REQUIRED > 101003
#define TCP_INFO TCP_CONNECTION_INFO
#define tcp_info tcp_connection_info
#endif
#endif

Once it works, I will submit a fix to upstream too.

Last edited 2 years ago by barracuda156 (previous) (diff)

comment:7 Changed 2 years ago by barracuda156

Yup, that worked:

10:~ svacchanda$ port -v installed haproxy
The following ports are currently installed:
  haproxy @2.6.3_0 (active) requested_variants='' platform='darwin 10' archs='ppc' date='2022-08-20T23:22:08+0800'

comment:8 Changed 2 years ago by barracuda156

Resolution: fixed
Status: assignedclosed

In faee4c50aca537f46546013b6e81bdb8033faab4/macports-ports (master):

haproxy: fix build for older OSs
Fixes: #65699

Note: See TracTickets for help on using tickets.