2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Make Linux headers of the host platform available to the program
|
|
|
|
#
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
include $(call select_from_repositories,lib/import/import-syscall-linux.mk)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Manually supply all library search paths of the host compiler to our tool
|
|
|
|
# chain.
|
|
|
|
#
|
2012-01-13 18:29:30 +00:00
|
|
|
HOST_LIB_SEARCH_DIRS = $(shell cc $(CC_MARCH) -print-search-dirs | grep libraries |\
|
|
|
|
sed "s/.*=//" | sed "s/:/ /g" |\
|
|
|
|
sed "s/\/ / /g" | sed "s/\/\$$//")
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Add search path for 'limits.h'
|
|
|
|
#
|
2011-12-23 13:04:29 +00:00
|
|
|
# We cannot simply extend 'INC_DIR' because this would give precedence to the
|
|
|
|
# host include search paths over Genode search path. The variable HOST_INC_DIR
|
|
|
|
# is appended to the include directory list.
|
|
|
|
#
|
|
|
|
HOST_INC_DIR += $(shell echo "int main() {return 0;}" |\
|
|
|
|
LANG=C $(CXX) -x c++ -v -E - 2>&1 |\
|
|
|
|
sed '/^\#include <\.\.\.> search starts here:/,/^End of search list/!d' |\
|
|
|
|
grep "include-fixed")
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Add search paths for normal libraries
|
|
|
|
#
|
|
|
|
CXX_LINK_OPT += $(addprefix -L,$(HOST_LIB_SEARCH_DIRS))
|
|
|
|
|
2011-12-22 16:23:09 +00:00
|
|
|
#
|
|
|
|
# Determine ldconfig executable
|
|
|
|
#
|
|
|
|
# On Ubuntu, /sbin/ is in the PATH variable. Hence we try using the program
|
|
|
|
# found via 'which'. If 'which' does not return anything (i.e., on Debian),
|
|
|
|
# try using the expected location '/sbin/'.
|
|
|
|
#
|
|
|
|
LDCONFIG := $(firstword $(wildcard $(shell which ldconfig) /sbin/ldconfig))
|
|
|
|
ifeq ($(LDCONFIG),)
|
|
|
|
$(error ldconfig is not found)
|
|
|
|
endif
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Add search paths for shared-library lookup
|
|
|
|
#
|
|
|
|
# We add all locations of shared libraries present in the ld.cache to our
|
|
|
|
# library search path.
|
|
|
|
#
|
2011-12-22 16:23:09 +00:00
|
|
|
HOST_SO_SEARCH_DIRS := $(sort $(dir $(shell $(LDCONFIG) -p | sed "s/^.* \//\//" | grep "^\/")))
|
2011-12-22 15:19:25 +00:00
|
|
|
LINK_ARG_PREFIX := -Wl,
|
|
|
|
CXX_LINK_OPT += $(addprefix $(LINK_ARG_PREFIX)-rpath-link $(LINK_ARG_PREFIX),$(HOST_SO_SEARCH_DIRS))
|
|
|
|
|
|
|
|
#
|
|
|
|
# Make exceptions work
|
|
|
|
#
|
|
|
|
CXX_LINK_OPT += -Wl,--eh-frame-hdr
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add all libraries and their dependencies specified at the 'LX_LIBS'
|
|
|
|
# variable to the linker command line
|
|
|
|
#
|
|
|
|
ifneq ($(LX_LIBS),)
|
2015-12-23 14:22:33 +00:00
|
|
|
LX_LIBS_OPT = $(shell pkg-config --static --libs $(LX_LIBS))
|
2011-12-22 15:19:25 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Use the host's startup codes, linker script, and dynamic linker
|
|
|
|
#
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
LD_TEXT_ADDR ?=
|
|
|
|
LD_SCRIPT_STATIC ?=
|
|
|
|
|
2012-01-13 18:29:30 +00:00
|
|
|
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crt1.o)
|
|
|
|
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crti.o)
|
2012-12-14 14:17:01 +00:00
|
|
|
EXT_OBJECTS += $(shell $(CUSTOM_CC) $(CC_MARCH) -print-file-name=crtbegin.o)
|
|
|
|
EXT_OBJECTS += $(shell $(CUSTOM_CC) $(CC_MARCH) -print-file-name=crtend.o)
|
2012-01-13 18:29:30 +00:00
|
|
|
EXT_OBJECTS += $(shell cc $(CC_MARCH) -print-file-name=crtn.o)
|
2015-12-23 14:22:33 +00:00
|
|
|
|
|
|
|
LX_LIBS_OPT += -lgcc -lgcc_s -lsupc++ -lc -lpthread
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
USE_HOST_LD_SCRIPT = yes
|
|
|
|
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
#
|
|
|
|
# We need to manually add the default linker script on the command line in case
|
|
|
|
# of standard library use. Otherwise, we were not able to extend it by the
|
|
|
|
# stack area section.
|
|
|
|
#
|
2011-12-22 15:19:25 +00:00
|
|
|
ifeq (x86_64,$(findstring x86_64,$(SPECS)))
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
CXX_LINK_OPT += -Wl,--dynamic-linker=/lib64/ld-linux-x86-64.so.2
|
|
|
|
LD_SCRIPT_DEFAULT = ldscripts/elf_x86_64.xc
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (x86_32,$(findstring x86_32,$(SPECS)))
|
|
|
|
CXX_LINK_OPT += -Wl,--dynamic-linker=/lib/ld-linux.so.2
|
|
|
|
LD_SCRIPT_DEFAULT = ldscripts/elf_i386.xc
|
2011-12-22 15:19:25 +00:00
|
|
|
endif
|
Disambiguate kernel-specific file names
This patch removes possible ambiguities with respect to the naming of
kernel-dependent binaries and libraries. It also removes the use of
kernel-specific global side effects from the build system. The reach of
kernel-specific peculiarities has thereby become limited to the actual
users of the respective 'syscall-<kernel>' libraries.
Kernel-specific build artifacts are no longer generated at magic places
within the build directory (like okl4's includes, or the L4 build
directories of L4/Fiasco and Fiasco.OC, or the build directories of
various kernels). Instead, such artifacts have been largely moved to the
libcache. E.g., the former '<build-dir>/l4/' build directory for the L4
build system resides at '<build-dir>/var/libcache/syscall-foc/build/'.
This way, the location is unique to the kernel. Note that various tools
are still generated somewhat arbitrarily under '<build-dir>/tool/' as
there is no proper formalism for building host tools yet.
As the result of this work, it has become possible to use a joint Genode
build directory that is usable with all kernels of a given hardware
platform. E.g., on x86_32, one can now seamlessly switch between linux,
nova, sel4, okl4, fiasco, foc, and pistachio without rebuilding any
components except for core, the kernel, the dynamic linker, and the timer
driver. At the current stage, such a build directory must still be
created manually. A change of the 'create_builddir' tool will follow to
make this feature easily available.
This patch also simplifies various 'run/boot_dir' plugins by removing
the option for an externally hosted kernel. This option remained unused
for many years now.
Issue #2190
2016-12-10 00:30:38 +00:00
|
|
|
|
|
|
|
ifeq (arm,$(findstring arm,$(SPECS)))
|
|
|
|
CXX_LINK_OPT += -Wl,--dynamic-linker=/lib/ld-linux.so.3
|
|
|
|
LD_SCRIPT_STATIC = ldscripts/armelf_linux_eabi.xc
|
2013-05-24 09:04:42 +00:00
|
|
|
endif
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-12-23 14:22:33 +00:00
|
|
|
#
|
|
|
|
# Because we use the host compiler's libgcc, omit the Genode toolchain's
|
|
|
|
# version and put all libraries here we depend on.
|
|
|
|
#
|
|
|
|
LD_LIBGCC = $(LX_LIBS_OPT)
|
2013-02-03 01:47:01 +00:00
|
|
|
|
|
|
|
# use the host c++ for linking to find shared libraries in DT_RPATH library paths
|
|
|
|
LD_CMD = c++
|
2015-05-15 15:35:01 +00:00
|
|
|
|
|
|
|
# disable format-string security checks, which prevent non-literal format strings
|
|
|
|
CC_OPT += -Wno-format-security
|
2016-12-27 19:51:42 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Disable position-independent executables (which are enabled by default on
|
|
|
|
# Ubuntu 16.10 or newer)
|
|
|
|
#
|
|
|
|
CXX_LINK_OPT_NO_PIE := $(shell \
|
|
|
|
(echo "int main(){}" | $(LD_CMD) -no-pie -x c++ - -o /dev/null >& /dev/null \
|
|
|
|
&& echo "-no-pie") || true)
|
|
|
|
CXX_LINK_OPT += $(CXX_LINK_OPT_NO_PIE)
|
|
|
|
|