2 PKG_TOOLCHAIN_DEPS += binutils-static gcc-static kernel-headers
4 include ../../core/glibc/glibc.nm
6 $(STAGE_BUILD): $(STAGE_PREPARE)
9 # Glibc uses a hard coded path for /etc/ld.so.preload. To keep Glibc from
10 # preloading libraries from the host machine perform the following command:
11 cd $(DIR_APP) && sed -e "s@/etc/ld.so.preload@$(TOOLS_DIR)@" -i elf/rtld.c
13 cd $(DIR_SRC)/glibc-build && \
16 ../$(THISAPP)/configure \
18 --prefix=$(TOOLS_DIR) \
19 --libexecdir=$(TOOLS_DIR)/lib/$(PKG_NAME) \
20 --with-headers=$(TOOLS_DIR)/include \
21 --with-binutils=$(TOOLS_DIR)/bin \
24 --enable-kernel=$(OPTIMIZED_KERNEL) \
28 --enable-stackguard-randomization
30 # Our GCC is already passing -fPIC, and that's all we want for the libraries.
31 # LDFLAGS.so is appended to so we don't build shared libraries with
32 # DT_TEXTREL (and to tell us if something goes wrong). For now we only build
33 # the libraries, not the programs:
34 echo "build-programs=no" \
35 >> $(DIR_SRC)/glibc-build/configparms
37 cd $(DIR_SRC)/glibc-build && make PARALLELMFLAGS=$(PARALLELISMFLAGS) \
38 CFLAGS="-O2 -DPIC -fno-stack-protector -U_FORTIFY_SOURCE" \
39 CXXFLAGS="-O2 -DPIC -fno-stack-protector -U_FORTIFY_SOURCE"
41 # Then build the programs with hardening, so everything possible in
42 # $(TOOLS_DIR) is hardened:
43 echo "CFLAGS = $(CFLAGS)" > $(DIR_SRC)/glibc-build/configparms
44 echo "CXXFLAGS = $(CXXFLAGS)" >> $(DIR_SRC)/glibc-build/configparms
45 cd $(DIR_SRC)/glibc-build && make PARALLELMFLAGS=$(PARALLELISMFLAGS) \
46 CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)"
51 $(STAGE_INSTALL): $(STAGE_BUILD)
54 -mkdir -v $(TOOLS_DIR)/etc
55 touch $(TOOLS_DIR)/etc/ld.so.conf
57 cd $(DIR_SRC)/glibc-build && make install