Skip to content

Commit

Permalink
[fix] Detect Clang (koreader#897)
Browse files Browse the repository at this point in the history
* Switch CircleCI to dedicated Clang Docker image

* Get rid of ancient Travis workarounds

* Get rid of weird CC prefixed with CCACHE situation, cf. koreader#897 (comment)
  • Loading branch information
Frenzie authored Apr 21, 2019
1 parent c64e3e0 commit 55ed4be
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 33 deletions.
14 changes: 0 additions & 14 deletions .ci/before_install.sh

This file was deleted.

3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ jobs:
- run:
name: install
command: |
source .ci/before_install.sh
source .ci/emulator_install.sh
- restore_cache:
Expand Down Expand Up @@ -117,6 +116,8 @@ jobs:

emu_clang_ninja:
<<: *EMU_TPL
docker:
- image: koreader/kobase-clang:0.1.0
environment:
<<: *EMU_ENV_LST
CC: "clang-7"
Expand Down
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ addons:
# libzmq workaround because we're using a positively ancient version, see https://github.com/zeromq/libzmq/pull/1497
- libtool-bin

before_install:
- if [ "$EMULATE_READER" = 1 ]; then source .ci/before_install.sh; fi

install:
- if [ "$EMULATE_READER" = 1 ]; then source .ci/emulator_install.sh; fi
- if [[ -n ${DOCKER_IMG+x} ]]; then docker pull $DOCKER_IMG; fi
Expand Down
28 changes: 14 additions & 14 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ ifdef SBOX_UNAME_MACHINE
endif

# set cross-compiler/host CC and CXX
ifeq ($(strip $(CCACHE) $(CC)), clang)
ifneq (,$(findstring clang, $(CC)))
ifdef CHOST
CC:=$(CHOST)-clang
CXX:=$(CHOST)-clang++
Expand Down Expand Up @@ -266,7 +266,7 @@ LIBTOOLIZE:=$(if $(DARWIN),glibtoolize,libtoolize)
ifndef DARWIN
# we need to set PATH manually here because export PATH in gmake only takes
# effect for for sub shells
STATIC_LIBSTDCPP=$(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -print-file-name=libstdc++.a)
STATIC_LIBSTDCPP=$(shell PATH='$(PATH)' $(CC) -print-file-name=libstdc++.a)
else
STATIC_LIBSTDCPP=
endif
Expand Down Expand Up @@ -339,7 +339,7 @@ ifeq ($(TARGET), kobo)
# NOTE: If we only care about Kobos w/ a Touch screen, we're good.
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=hard
ifeq ($(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -dumpmachine 2>/dev/null), arm-linux-gnueabihf)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabihf)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
Expand All @@ -356,21 +356,21 @@ else ifeq ($(TARGET), pocketbook)
else ifeq ($(TARGET), kindle)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
else ifeq ($(TARGET), kindlepw2)
ARM_ARCH:=$(ARMV7_A9_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
else ifeq ($(TARGET), kindle-legacy)
ARM_ARCH:=$(ARMV6_1136_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(MG2K12_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(MG2K12_COMPAT_CXXFLAGS)
endif
Expand All @@ -395,7 +395,7 @@ else ifeq ($(TARGET), sony-prstux)
else ifeq ($(TARGET), cervantes)
ARM_ARCH:=$(ARMV7_GENERIC_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
Expand Down Expand Up @@ -427,11 +427,11 @@ endif
# Anything below GCC 6 gets to be forcefully switched to decent standards, because some of our deps require C11 & C++11 support.
# NOTE: Technically, this also means we require Clang >= 3.2, but that should more or less hold true on our end, because that's truly ancient.
# Tests heavily inspired from Linux's build system ;).
CC_IS_CLANG:=$(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -v 2>&1 | grep -q "clang version" && echo 1 || echo 0)
CC_VERSION:=$(shell PATH='$(PATH)' printf "%02d%02d%02d" `echo __GNUC__ | $(strip $(CCACHE) $(CC)) -E -x c - | tail -n 1` `echo __GNUC_MINOR__ | $(strip $(CCACHE) $(CC)) -E -x c - | tail -n 1` `echo __GNUC_PATCHLEVEL__ | $(strip $(CCACHE) $(CC)) -E -x c - | tail -n 1`)
CC_IS_CLANG:=$(shell PATH='$(PATH)' $(CC) -v 2>&1 | grep -q "clang version" && echo 1 || echo 0)
CC_VERSION:=$(shell PATH='$(PATH)' printf "%02d%02d%02d" `echo __GNUC__ | $(CC) -E -x c - | tail -n 1` `echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1` `echo __GNUC_PATCHLEVEL__ | $(CC) -E -x c - | tail -n 1`)
# Detect Clang's SA, too...
ifeq "$(CC_IS_CLANG)" "0"
ifeq "$(lastword $(subst /, ,$(strip $(CCACHE) $(CC))))" "ccc-analyzer"
ifeq "$(lastword $(subst /, ,$(CC)))" "ccc-analyzer"
CC_IS_CLANG:=1
endif
endif
Expand Down Expand Up @@ -476,7 +476,7 @@ ifdef STATICLIBSTDCPP
endif

# this will create a path named build/arm-none-linux-gnueabi or similar
TARGET_MARCHINE:=$(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -dumpmachine 2>/dev/null)
TARGET_MARCHINE:=$(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null)
ifdef KODEBUG
MACHINE=$(TARGET_MARCHINE)-debug
else
Expand Down Expand Up @@ -513,7 +513,7 @@ else
# Use a CMake toolchain file to avoid all kinds of CMake insanity
export CROSS_TC:=$(CHOST)
ifndef SYSROOT
export SYSROOT:=$(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -print-sysroot)
export SYSROOT:=$(shell PATH='$(PATH)' $(CC) -print-sysroot)
endif
export CROSS_STAGING:=$(CURDIR)/$(OUTPUT_DIR)
export CMAKE_TCF:=-DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/thirdparty/cmake_modules/CMakeCross.cmake
Expand All @@ -527,7 +527,7 @@ else
# Don't let libtool piss on our parade...
# See what was mentioned around STATIC_LIBSTDCPP on ~L#93 for more details
# (cf. https://www.gnu.org/software/libtool/manual/html_node/Stripped-link-flags.html#Stripped-link-flags)
CC:=$(strip $(CCACHE) $(CC)) -static-libstdc++
CC:=$(CC) -static-libstdc++
CXX:=$(strip $(CCACHE) $(CXX)) -static-libstdc++
CFLAGS+=$(ARM_ARCH) $(COMPAT_CFLAGS) -static-libstdc++
CXXFLAGS+=$(ARM_ARCH) $(COMPAT_CXXFLAGS) -static-libstdc++
Expand Down Expand Up @@ -579,7 +579,7 @@ ifndef WIN32
# We only care about that on non-emulated builds (i.e., arm), because compat symbols may be pinned
# to different versions on different arches, and we only account for arm in our patches.
ifndef EMULATE_READER
GLIBC_FILE=$(basename $(notdir $(realpath $(shell PATH='$(PATH)' $(strip $(CCACHE) $(CC)) -print-file-name=libc.so.6))))
GLIBC_FILE=$(basename $(notdir $(realpath $(shell PATH='$(PATH)' $(CC) -print-file-name=libc.so.6))))
GLIBC_VER=$(shell echo $(GLIBC_FILE) | cut -f2 -d'-')
GLIBC_2_22_SORT=$(shell echo -e "$(GLIBC_VER)\n2.22" | sort -V | head -n1)
ifeq ($(GLIBC_2_22_SORT), 2.22)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Device emulation

The code also features a device emulation. You need SDL headers and library
for this. It allows to develop on a standard PC and saves precious development
time. It might also compose the most unfriendly desktop PDF reader, depending
time. It might also create a suboptimal desktop PDF viewer, depending
on your view.

If you are using Fedora Core Linux, run `yum install SDL2 SDL2-devel`.
Expand Down

0 comments on commit 55ed4be

Please sign in to comment.