concurrencykit / ck

Concurrency primitives, safe memory reclamation mechanisms and non-blocking (including lock-free) data structures designed to aid in the research, design and implementation of high performance concurrent systems developed in C99+.
http://concurrencykit.org/
Other
2.34k stars 312 forks source link

custom configure script broken for cross-compilation #191

Closed Apteryks closed 2 years ago

Apteryks commented 2 years ago

Hi!

I've been trying to package this for Guix, and it's been brought during review that cross-compilation was not handled by the script (such as I've come to expect from a configure script, thanks to Autotools).

Instead, one has to define CC, AR and LD themselves as environment variables, then derive the machine in the format expected by the ck's configure script (e.g. arm-linux-gnuabihf --> arm or i586 --> x86) and provide it as the --profile option.

Finally, that doesn't seem to be enough, as LDFLAGS gets set according to the host platform and is not always overriden in the ck.build* override files such as the ck.build.arm one. E.g., building using arm-linux-gnuabihf as the target, on my x86_64-linux machine, the configure script reports:

Detecting operating system.......success [linux]
Detecting machine architecture...success [x86_64]
Finding dirname command..........success [/gnu/store/d251rfgc9nm2clzffzhgiipdvfvzkvwi-coreutils-8.32/bin/dirname]
Determining build directory......success [/tmp/guix-build-ck-0.7.1.drv-0/source]
Finding gzip tool................success [/gnu/store/iixwcv3k49ks1rf34pjgfzmzyhhgwng3-gzip-1.10/bin/gzip]
Using user-specified profile.....success [arm]
Generating header files..........success
Generating build files...........success

           VERSION = 0.7.1
           GIT_SHA = 
         BUILD_DIR = /tmp/guix-build-ck-0.7.1.drv-0/source
           SRC_DIR = /tmp/guix-build-ck-0.7.1.drv-0/source
            SYSTEM = linux
           PROFILE = arm
                AR = arm-linux-gnueabihf-ar
                CC = arm-linux-gnueabihf-gcc
          COMPILER = 
            CFLAGS = 
    PTHREAD_CFLAGS = 
                LD = arm-linux-gnueabihf-ld
            LDNAME = libck.so
    LDNAME_VERSION = libck.so.0.7.1
      LDNAME_MAJOR = libck.so.0
           LDFLAGS = -m64 
        STATIC_LIB = 0
              GZIP = /gnu/store/iixwcv3k49ks1rf34pjgfzmzyhhgwng3-gzip-1.10/bin/gzip -c
             CORES = 24
      POINTER_PACK = CK_MD_POINTER_PACK_DISABLE
      PPC32_LWSYNC = CK_MD_PPC32_LWSYNC_DISABLE
          VMA_BITS = unknown
      MEMORY_MODEL = CK_MD_TSO
               RTM = CK_MD_RTM_DISABLE
               LSE = CK_MD_LSE_DISABLE
               SSE = CK_MD_SSE_ENABLE

The -m64 in the LDFLAGS seems wrong, and SSE appears to be enabled.

Also, 'make all' doesn't actually build anything, because of this check in configure:

$CC -o .1 .1.c
COMPILER=`./.1 2> /dev/null`

Since the compiler is a cross-compiler, executing the compiled .1 binary fails and COMPILER remains unset, which in turns make ALL_LIBS unset as well, causing the build to not build any library.

There's a reason build systems exist; I'd suggest to use one :-).

Thanks!

sbahra commented 2 years ago

Unfortunately, the configure script does not support cross-compilation. The expectation is to use --profile for cross-compiling with your settings in a .build file. I would absolutely love patches though to fix this behavior but unfortunately, no cycles on my end and it's a lower priority issue.

Apteryks commented 2 years ago

Just for my info, would using a build system such as Autotools that already handles cross-compilation correctly be an acceptable solution to you?