From 8ed555dbac12e0cbf92da8c38293a54982715170 Mon Sep 17 00:00:00 2001 From: Brandon Curtis Date: Thu, 18 Aug 2016 01:40:29 -0700 Subject: [PATCH 1/2] 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. --- Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Makefile b/Makefile index ce97c5efae..61b226bace 100644 --- a/Makefile +++ b/Makefile @@ -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 $@ $< From 5e9f4470c77b49747818410195841b88b25862fa Mon Sep 17 00:00:00 2001 From: Brandon Curtis Date: Fri, 19 Aug 2016 04:55:06 -0700 Subject: [PATCH 2/2] Use `U3_OS_LoomBits` To Set Reserved Memory Size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The size and starting position of Urbit's reserved memory block is set by `U3_OS_LoomBits` and `U3_OS_LoomBase` in `include/c/portable.h`. `U3_OS_LoomBase` is referenced in `include/noun/allocate.h` and sets the position in memory of u3_Loom. This is good. However, `U3_OS_LoomBits` is not actually used to set the size of the reserved memory block. Instead: in `include/allocate.h`, - `u3a_bits` is defined - `u3a_bits` → `u3a_bytes` in `noun/manage.c`, - `u3a_bytes` → `len_w` in `_cm_init()` - `len_w` sets the reserved memory block size This proposal puts `U3_OS_LoomBits` back to work by defining `u3a_bits` with it. --- include/noun/allocate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 7ab6b2139d..68de4afb8b 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -23,7 +23,7 @@ **/ /* u3a_bits: number of bits in word-addressed pointer. 29 == 2GB. */ -# define u3a_bits 29 +# define u3a_bits U3_OS_LoomBits /* u3a_page: number of bits in word-addressed page. 12 == 16Kbyte page. */