Zstd: Build issue with make 4.3

Created on 1 Feb 2020  路  2Comments  路  Source: facebook/zstd

When building zstd 1.4.4 with make 4.3, multi-threading/zlib/liblzma/liblz4 support is disabled at build time. It seems that make 4.3 interprets '\#' literally rather than interpreting it as escaped '#' in the shell function. For example for multi-threading support, the compilation test on line programsMakefile:99 always fails with make 4.3 because \#include <pthread.h> is a wrong statement, so HAVE_PTHREAD is always set to 0. The issue doesn't exist with make 4.2.1

programsMakefile:99

HAVE_PTHREAD := $(shell printf '\#include <pthread.h>\nint main(void) { return 0; }' > have_pthread.c && $(CC) $(FLAGS) -o have_pthread$(EXT) have_pthread.c -pthread 2> $(VOID) && rm have_pthread$(EXT) && echo 1 || echo 0; rm have_pthread.c)

Build log snippet with Make 4.3:

......
==> no threads, building without multithreading support
==> no zlib, building zstd without .gz support
==> no liblzma, building zstd without .xz/.lzma support
==> no liblz4, building zstd without .lz4 support
......

Build log snippet with Make 4.2.1:

......
==> building with threading support
==> building zstd with .gz compression support
==> building zstd with .xz/.lzma compression support
==> building zstd with .lz4 compression support
......
build issue

Most helpful comment

It looks like the workround that gnu provides for this is pretty straightforward (https://lwn.net/Articles/810071/)

If you want to write makefiles portable to both versions
assign the number sign to a variable:

    H := \#
    foo := $(shell echo '$H')

I prefer just doing this to the current programs/Makefile over what @davidbolvansky proposes because it will require less change:).

I'll put up a pr in a sec and we can move forward with this solution unless someone wants to make a strong case for the other approach.

All 2 comments

https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html

Can we use __has_include? gcc/clang supports this builtin.

It looks like the workround that gnu provides for this is pretty straightforward (https://lwn.net/Articles/810071/)

If you want to write makefiles portable to both versions
assign the number sign to a variable:

    H := \#
    foo := $(shell echo '$H')

I prefer just doing this to the current programs/Makefile over what @davidbolvansky proposes because it will require less change:).

I'll put up a pr in a sec and we can move forward with this solution unless someone wants to make a strong case for the other approach.

Was this page helpful?
0 / 5 - 0 ratings