Skip to content
Snippets Groups Projects
Commit a88888b6 authored by Boqun Feng's avatar Boqun Feng Committed by Pekka Enberg
Browse files

build.mk: introduce *_env variables to make system

According to http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

,
the versions of standard libraries have a strong matchup with versions
of compilers, so linkage errors occur when using libstdc++ in *external*
submodule when using GCC 4.9.0.

As there is such a mixup in the build system, the environments of
standard libraries in link time should be switchable to support GCC
whose version doesn't match up with external's.

*_env variables are introduced. To build a image with standard libraries
in the host, run `make build_env=host'. For fine-grained settings, use
gcc_lib_env and cxx_lib_env.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarBoqun Feng <boqun.feng@linux.vnet.ibm.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 7b475da9
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,19 @@ By default make creates image in qcow2 format. To change this pass format value
make img_format=raw
```
By default make will use the static libraries of gcc in external submodule. To change this pass `host' via *_env variables:
```
make build_env=host
```
This will use static libraries in the system instead (make sure they are installed before run `make'),
if you only want to use C++ static libraries in the system, just set cxx_lib_env to `host':
```
make cxx_lib_env=host
```
## Running OSv
```
......
......@@ -11,6 +11,15 @@ else
OBJCOPY=$(CROSS_PREFIX)objcopy
endif
build_env ?= external
ifeq ($(build_env), host)
gcc_lib_env ?= host
cxx_lib_env ?= host
else
gcc_lib_env ?= external
cxx_lib_env ?= external
endif
detect_arch=$(shell echo $(1) | $(CC) -E -xc - | tail -n 1)
ifndef ARCH
......@@ -25,6 +34,7 @@ else
endif
$(info build.mk:)
$(info build.mk: building arch=$(arch), override with ARCH env)
$(info build.mk: building build_env=$(build_env) gcc_lib_env=$(gcc_lib_env) cxx_lib_env=$(cxx_lib_env))
$(info build.mk:)
image ?= default
......@@ -820,10 +830,35 @@ include $(src)/libc/build.mk
objects += $(addprefix fs/, $(fs))
objects += $(addprefix libc/, $(libc))
libstdc++.a = $(shell find $(gccbase)/ -name libstdc++.a)
libsupc++.a = $(shell find $(gccbase)/ -name libsupc++.a)
libgcc_s.a = $(shell find $(gccbase)/ -name libgcc.a | grep -v /32/)
libgcc_eh.a = $(shell find $(gccbase)/ -name libgcc_eh.a | grep -v /32/)
ifeq ($(cxx_lib_env), host)
libstdc++.a := $(shell $(CXX) -print-file-name=libstdc++.a)
ifeq ($(filter /%,$(libstdc++.a)),)
$(error Error: libstdc++.a needs to be installed.)
endif
libsupc++.a := $(shell $(CXX) -print-file-name=libsupc++.a)
ifeq ($(filter /%,$(libsupc++.a)),)
$(error Error: libsupc++.a needs to be installed.)
endif
else
libstdc++.a := $(shell find $(gccbase)/ -name libstdc++.a)
libsupc++.a := $(shell find $(gccbase)/ -name libsupc++.a)
endif
ifeq ($(gcc_lib_env), host)
libgcc.a := $(shell $(CC) -print-libgcc-file-name)
ifeq ($(filter /%,$(libgcc.a)),)
$(error Error: libgcc.a needs to be installed.)
endif
libgcc_eh.a := $(shell $(CC) -print-file-name=libgcc_eh.a)
ifeq ($(filter /%,$(libgcc_eh.a)),)
$(error Error: libgcc_eh.a needs to be installed.)
endif
else
libgcc_s.a := $(shell find $(gccbase)/ -name libgcc.a | grep -v /32/)
libgcc_eh.a := $(shell find $(gccbase)/ -name libgcc_eh.a | grep -v /32/)
endif
boost-lib-dir := $(shell dirname `find $(miscbase)/ -name libboost_system-mt.a`)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment