Workaround for glibc >2.24 compilation failure

`glibc 2.24` deprecated `readdir_r` and patched `readdir` for threadsafeness.  This Makefile upgrades warnings to errors with `CWFLAGS=-Werror`, so compilation fails in the presence of `glibc >2.24`.  This is a problem in Arch today, and other distros in the near future.

The best solution may be to check the `glibc` version and replace `readdir_r` with `readdir` if `glibc >2.24`.  In the meantime, using `CWFLAGS+=-Wno-error=deprecated-declarations` in the Makefile in the case of `glibc >2.24` allows `glibc 2.24` users to compile Urbit.

Depends on `getconf` and `expr` shell built-ins, which should be available everywhere.
This commit is contained in:
Brandon Curtis 2016-08-18 01:40:29 -07:00 committed by GitHub
parent 0c3ec4c7fd
commit 8ed555dbac

View File

@ -134,6 +134,20 @@ ifneq ($(OS),bsd)
CWFLAGS+=-Wno-error=unused-result
endif
# glibc 2.24 deprecates readdir_r; iff glibc >=2.24,
# don't upgrade 'deprecated declarations' warnings to errors
# dependency: `getconf`, which comes w/glibc
GLIBC := $(lastword $(shell getconf GNU_LIBC_VERSION))
# dependency: none, uses make's native functions
GLIBC_MAJ := $(word 1, $(subst ., ,$(GLIBC)))
GLIBC_MIN := $(word 2, $(subst ., ,$(GLIBC)))
# dependency: `expr` shell built-in
GLIBC_GE_2_24 := $(shell expr $(GLIBC_MAJ) ">" 2 "|" \
$(GLIBC_MAJ) "=" 2 "&" $(GLIBC_MIN) ">=" 24)
ifeq (1,$(GLIBC_GE_2_24))
CWFLAGS+=-Wno-error=deprecated-declarations
endif
ifdef NO_SILENT_RULES
%.o: %.c $(CORE)
$(CC) -c $(CWFLAGS) $(CFLAGS) -o $@ $<