From 36479ddc1a92ff5a8a2acda6b1af8e4644f38b7b Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Thu, 16 Nov 2017 16:19:00 +0100 Subject: [PATCH] Remove the 'external' toolchain file (#2089) The 'external' toolchain file does nothing but transitively sets some cmake system variables from values received on the command line, and forcibly sets the C compiler. However, the same cmake system variables can be directly set via the command line, together with the C compiler, and specifying a toolchain is not a must. Thus, this patch drops the superfluous 'external' toolchain file and updates cmake-based targets to invoke cmake in a simpler form. Related changes in this commit: - While updating the cmake invocations, all the command line arguments have been reviewed and simplified (removed those, which did not change the defaults). - Removed unnecessary forced C compiler settings from some toolchain files (and/or changed them to setting the "compiler works" flag to true, thus keeping cmake's compiler identification logic but disabling some of its overzealous compiler sanity checks). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu --- cmake/toolchain_external.cmake | 20 ------------------- cmake/toolchain_mcu_stm32f3.cmake | 5 ++--- cmake/toolchain_mcu_stm32f4.cmake | 5 ++--- targets/esp8266/Makefile.esp8266 | 14 ++++++------- targets/mbed/Makefile.mbed | 11 +++++------ targets/particle/Makefile.particle | 24 ++++++----------------- targets/riot-stm32f4/Makefile.riot | 15 +++++++------- targets/tizenrt-artik053/Makefile.tizenrt | 11 +++++------ targets/zephyr/Makefile.zephyr | 16 +++++++-------- 9 files changed, 40 insertions(+), 81 deletions(-) delete mode 100644 cmake/toolchain_external.cmake diff --git a/cmake/toolchain_external.cmake b/cmake/toolchain_external.cmake deleted file mode 100644 index e481b7ec8..000000000 --- a/cmake/toolchain_external.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright JS Foundation and other contributors, http://js.foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include(CMakeForceCompiler) - -set(CMAKE_SYSTEM_NAME EXTERNAL) -set(CMAKE_SYSTEM_PROCESSOR "${EXTERNAL_CMAKE_SYSTEM_PROCESSOR}") - -CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} ${EXTERNAL_CMAKE_C_COMPILER_ID}) diff --git a/cmake/toolchain_mcu_stm32f3.cmake b/cmake/toolchain_mcu_stm32f3.cmake index 039853539..d9333cf79 100644 --- a/cmake/toolchain_mcu_stm32f3.cmake +++ b/cmake/toolchain_mcu_stm32f3.cmake @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -include(CMakeForceCompiler) - set(CMAKE_SYSTEM_NAME MCU) set(CMAKE_SYSTEM_PROCESSOR armv7l) set(CMAKE_SYSTEM_VERSION STM32F3) set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard) -CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU) +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_C_COMPILER_WORKS TRUE) diff --git a/cmake/toolchain_mcu_stm32f4.cmake b/cmake/toolchain_mcu_stm32f4.cmake index e058f7c32..768cd7c01 100644 --- a/cmake/toolchain_mcu_stm32f4.cmake +++ b/cmake/toolchain_mcu_stm32f4.cmake @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -include(CMakeForceCompiler) - set(CMAKE_SYSTEM_NAME MCU) set(CMAKE_SYSTEM_PROCESSOR armv7l) set(CMAKE_SYSTEM_VERSION STM32F4) set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard) -CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU) +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_C_COMPILER_WORKS TRUE) diff --git a/targets/esp8266/Makefile.esp8266 b/targets/esp8266/Makefile.esp8266 index 5bc854db3..804192c13 100644 --- a/targets/esp8266/Makefile.esp8266 +++ b/targets/esp8266/Makefile.esp8266 @@ -44,16 +44,14 @@ jerry: mkdir -p $(BUILD_DIR) mkdir -p $(COPYTARGET) cmake -B$(BUILD_DIR) -H./ \ + -DCMAKE_SYSTEM_NAME=MCU \ + -DCMAKE_SYSTEM_PROCESSOR=xtensia-lx106 \ + -DCMAKE_C_COMPILER=xtensa-lx106-elf-gcc \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ -DENABLE_LTO=OFF \ - -DFEATURE_VALGRIND=OFF \ - -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \ - -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=xtensia-lx106 \ - -DEXTERNAL_CMAKE_C_COMPILER=xtensa-lx106-elf-gcc \ - -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ - -DJERRY_LIBC=OFF \ - -DJERRY_LIBM=ON \ - -DJERRY_CMDLINE=OFF \ -DENABLE_ALL_IN_ONE=ON \ + -DJERRY_LIBC=OFF \ + -DJERRY_CMDLINE=OFF \ -DEXTERNAL_COMPILE_FLAGS="$(ESP_CFLAGS)" \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) diff --git a/targets/mbed/Makefile.mbed b/targets/mbed/Makefile.mbed index ea2b59b6c..29529c99f 100644 --- a/targets/mbed/Makefile.mbed +++ b/targets/mbed/Makefile.mbed @@ -53,15 +53,14 @@ jerry: mkdir -p $(COPYTARGET) mkdir -p $(BUILD_DIR) cmake -B$(BUILD_DIR) -H./ \ + -DCMAKE_SYSTEM_NAME=Mbed \ + -DCMAKE_SYSTEM_PROCESSOR=armv7l-hf \ + -DCMAKE_C_COMPILER=arm-none-eabi-gcc \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ -DENABLE_LTO=OFF \ - -DFEATURE_VALGRIND=OFF \ - -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \ + -DENABLE_ALL_IN_ONE=OFF \ -DJERRY_LIBC=OFF \ -DJERRY_CMDLINE=OFF \ - -DENABLE_ALL_IN_ONE=OFF \ - -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l-hf \ - -DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \ - -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \ diff --git a/targets/particle/Makefile.particle b/targets/particle/Makefile.particle index 637b0f17a..7c5cea8ee 100644 --- a/targets/particle/Makefile.particle +++ b/targets/particle/Makefile.particle @@ -39,30 +39,18 @@ all: jerrycore jerry-main jerrycore: mkdir -p $(BUILD_DIR) cmake -B$(BUILD_DIR) -H./ \ + -DCMAKE_SYSTEM_NAME=MCU \ + -DCMAKE_SYSTEM_PROCESSOR=armv7l \ + -DCMAKE_C_COMPILER=arm-none-eabi-gcc \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DENABLE_LTO=ON \ + -DENABLE_ALL_IN_ONE=OFF \ -DJERRY_LIBC=OFF \ -DJERRY_LIBM=OFF \ -DJERRY_CMDLINE=OFF \ - -DUNITTESTS=OFF \ - -DENABLE_LTO=ON \ -DFEATURE_PROFILE=minimal \ - -DCMAKE_TOOLCHAIN_FILE=$(JERRYDIR)/cmake/toolchain_external.cmake \ - -DENABLE_ALL_IN_ONE=OFF \ -DENABLE_STRIP=OFF \ - -DENABLE_STATIC_LINK=ON \ - -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \ - -DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \ - -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ - -DFEATURE_ERROR_MESSAGES=OFF \ - -DFEATURE_VALGRIND=OFF \ - -DFEATURE_VALGRIND_FREYA=OFF \ - -DFEATURE_CPOINTER_32_BIT=OFF \ - -DFEATURE_MEM_STRESS_TEST=OFF \ - -DFEATURE_MEM_STATS=OFF \ - -DFEATURE_PARSER_DUMP=OFF \ - -DFEATURE_REGEXP_DUMP=OFF \ - -DFEATURE_SNAPSHOT_SAVE=OFF \ - -DFEATURE_SNAPSHOT_EXEC=OFF \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) make -C$(BUILD_DIR) jerry-core diff --git a/targets/riot-stm32f4/Makefile.riot b/targets/riot-stm32f4/Makefile.riot index 99c4afe6f..81d9392a0 100644 --- a/targets/riot-stm32f4/Makefile.riot +++ b/targets/riot-stm32f4/Makefile.riot @@ -29,16 +29,15 @@ libjerry: mkdir -p $(BUILD_DIR) mkdir -p $(COPYTARGET) cmake -B$(BUILD_DIR) -H./ \ + -DCMAKE_SYSTEM_NAME=RIOT \ + -DCMAKE_SYSTEM_PROCESSOR=armv7l \ + -DCMAKE_C_COMPILER=arm-none-eabi-gcc \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ -DENABLE_LTO=OFF \ - -DFEATURE_VALGRIND=OFF \ - -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \ - -DJERRY_LIBM=OFF \ - -DJERRY_LIBC=OFF \ - -DJERRY_CMDLINE=OFF \ -DENABLE_ALL_IN_ONE=OFF \ - -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \ - -DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \ - -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ + -DJERRY_LIBC=OFF \ + -DJERRY_LIBM=OFF \ + -DJERRY_CMDLINE=OFF \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) diff --git a/targets/tizenrt-artik053/Makefile.tizenrt b/targets/tizenrt-artik053/Makefile.tizenrt index 8a45b272c..339149d7e 100644 --- a/targets/tizenrt-artik053/Makefile.tizenrt +++ b/targets/tizenrt-artik053/Makefile.tizenrt @@ -32,15 +32,14 @@ libjerry: mkdir -p $(BUILD_DIR) mkdir -p $(LIBTARGET_DIR) cmake -B$(BUILD_DIR) -H./ \ + -DCMAKE_SYSTEM_NAME=TizenRT \ + -DCMAKE_SYSTEM_PROCESSOR=armv7l \ + -DCMAKE_C_COMPILER=arm-none-eabi-gcc \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ -DENABLE_LTO=OFF \ - -DFEATURE_VALGRIND=OFF \ - -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \ + -DENABLE_ALL_IN_ONE=OFF \ -DJERRY_LIBC=OFF \ -DJERRY_CMDLINE=OFF \ - -DENABLE_ALL_IN_ONE=OFF \ - -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l \ - -DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \ - -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \ -DCMAKE_BUILD_TYPE=Release diff --git a/targets/zephyr/Makefile.zephyr b/targets/zephyr/Makefile.zephyr index c35272009..54b1681ac 100644 --- a/targets/zephyr/Makefile.zephyr +++ b/targets/zephyr/Makefile.zephyr @@ -77,21 +77,19 @@ endif mkdir -p $(INTERM) mkdir -p $(OUTPUT) cmake -B$(INTERM) -H./ \ - -DENABLE_LTO=OFF \ - -DFEATURE_VALGRIND=OFF \ + -DCMAKE_SYSTEM_NAME=Zephyr \ + -DCMAKE_C_COMPILER="$(subst ccache ,,$(CC))" \ + -DCMAKE_C_COMPILER_WORKS=TRUE \ + -DENABLE_LTO=OFF \ + -DENABLE_ALL_IN_ONE=OFF \ + -DJERRY_LIBC=OFF \ + -DJERRY_CMDLINE=OFF \ -DFEATURE_PROFILE=$(JERRYPROFILE) \ -DFEATURE_ERROR_MESSAGES=ON \ -DCMAKE_BUILD_TYPE=MinSizeRel \ -DCMAKE_VERBOSE_MAKEFILE=$(V) \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \ - -DEXTERNAL_CMAKE_C_COMPILER="$(subst ccache ,,$(CC))" \ - -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ - -DJERRY_CMDLINE=OFF \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ - -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \ - -DFEATURE_SNAPSHOT_EXEC=OFF \ - -DENABLE_ALL_IN_ONE=OFF \ - -DJERRY_LIBC=OFF \ $(EXT_JERRY_FLAGS) make -C $(INTERM) $(COMPONENTS) V=1