diff --git a/.travis.yml b/.travis.yml index 79064b84a..edef79c5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,10 @@ matrix: - env: TARGET=x86_64-apple-darwin-macho USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO os: osx - - env: TARGET=x86-apple-darwin-macho USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-apple-darwin-macho USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG os: osx - - env: TARGET=x86-apple-darwin-macho USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-apple-darwin-macho USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO os: osx - env: TARGET=x86_64-pc-linux-gnu USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG @@ -145,7 +145,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -159,7 +159,7 @@ matrix: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -173,7 +173,7 @@ matrix: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -187,7 +187,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -201,7 +201,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -215,7 +215,7 @@ matrix: - llvm-toolchain-precise-3.5 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -229,7 +229,7 @@ matrix: - llvm-toolchain-precise-3.5 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -241,7 +241,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -253,7 +253,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -267,7 +267,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -281,7 +281,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -292,7 +292,7 @@ matrix: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -303,7 +303,7 @@ matrix: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -314,7 +314,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -325,7 +325,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -336,7 +336,7 @@ matrix: - llvm-toolchain-precise-3.5 - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -347,21 +347,21 @@ matrix: - llvm-toolchain-precise-3.5 - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: packages: - yasm - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: packages: - yasm - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -372,7 +372,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -383,7 +383,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=gcc-4.9 USE_CXX=g++-4.9 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-4.9 USE_CXX=g++-4.9 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -394,7 +394,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86_64-pc-linux-gnu NO_ASM=1 USE_CC=gcc-4.9 USE_CXX=g++-4.9 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=x86_64-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-4.9 USE_CXX=g++-4.9 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -405,7 +405,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -419,7 +419,7 @@ matrix: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.6 USE_CXX=clang++-3.6 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -433,7 +433,7 @@ matrix: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -447,7 +447,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-4.8 USE_CXX=g++-4.8 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -461,7 +461,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -475,7 +475,7 @@ matrix: - llvm-toolchain-precise-3.5 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang-3.5 USE_CXX=clang++-3.5 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -489,7 +489,7 @@ matrix: - llvm-toolchain-precise-3.5 - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -501,7 +501,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=clang USE_CXX=clang++ CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: @@ -513,7 +513,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=DEBUG + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=DEBUG os: linux addons: apt: @@ -527,7 +527,7 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: TARGET=x86-pc-linux-gnu NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=RELWITHDEBINFO + - env: TARGET=i586-pc-linux-gnu NO_ASM=NO_ASM=1 USE_CC=gcc-5 USE_CXX=g++-5 CMAKE_BUILD_TYPE=RELWITHDEBINFO os: linux addons: apt: diff --git a/BUILDING.md b/BUILDING.md index 7d33af03e..a104b4d65 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -25,14 +25,13 @@ expects variables ```CC```, ```CXX```, and ```TARGET``` to be passed to ```make```. For example, this will build a 32-bit x86 *ring* for Linux using GCC 4.8: - make -j6 CC=gcc-4.8 CXX=g++-4.8 TARGET=x86-pc-linux-gnu + make -j6 CC=gcc-4.8 CXX=g++-4.8 TARGET=i586-pc-linux-gnu As another example, this will build a 64-bit x86-64 *ring* for Mac OS X: make -j6 CC=clang CXX=clang++ TARGET=x86_64-apple-darwin-macho -All four parts of the target are required. ```x86``` must be used instead -of ```i386```, ```i586```, etc. +All four parts of the target are required. GCC 4.8 and later are supported, as are clang 3.4 and later. Other compilers will also probably work without too much trouble. Note in particular that if diff --git a/crypto/modes/gcm.c b/crypto/modes/gcm.c index 593dce886..dd05d1218 100644 --- a/crypto/modes/gcm.c +++ b/crypto/modes/gcm.c @@ -350,7 +350,7 @@ void gcm_ghash_4bit_x86(uint64_t Xi[2], const u128 Htable[16], const uint8_t *in #endif #elif defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) #include -#if __ARM_ARCH__ >= 7 +#if __ARM_MAX_ARCH__ >= 8 #define GHASH_ASM_ARM #define GCM_FUNCREF_4BIT diff --git a/include/openssl/arm_arch.h b/include/openssl/arm_arch.h index 123a890d4..89fa2e7e7 100644 --- a/include/openssl/arm_arch.h +++ b/include/openssl/arm_arch.h @@ -100,7 +100,9 @@ /* Even when building for 32-bit ARM, support for aarch64 crypto instructions * will be included. */ +#if !defined(__ARM_MAX_ARCH__) #define __ARM_MAX_ARCH__ 8 +#endif #if !__ASSEMBLER__ diff --git a/mk/bottom_of_makefile.mk b/mk/bottom_of_makefile.mk index 55800c092..7263a05fb 100644 --- a/mk/bottom_of_makefile.mk +++ b/mk/bottom_of_makefile.mk @@ -31,7 +31,8 @@ $(GENERATED) : | $(GENERATED_DIRS) %.o: %.S $(COMPILE.c) $(OUTPUT_OPTION) $< - +$(OBJ_PREFIX)%.o: %.S + $(COMPILE.c) $(OUTPUT_OPTION) $< $(OBJ_PREFIX)%.o: %.c $(COMPILE.c) $(OUTPUT_OPTION) $< $(OBJ_PREFIX)%.o: %.cpp diff --git a/mk/ring.mk b/mk/ring.mk index c0121e2ec..26f7c11f6 100644 --- a/mk/ring.mk +++ b/mk/ring.mk @@ -14,23 +14,10 @@ RING_PREFIX ?= ring/ -RING_CPPFLAGS = -I$(RING_PREFIX)include -D_XOPEN_SOURCE=700 +RING_CPPFLAGS = $(RING_THREAD_FLAGS) -I$(RING_PREFIX)include -D_XOPEN_SOURCE=700 -RING_LDLIBS = -pthread -L$(dir $(RING_LIB)) -lring +RING_LDLIBS = $(RING_THREAD_FLAGS) -L$(dir $(RING_LIB)) -lring -# Everything, except: -# * Tests (e.g. *_test.*) -# * Assembly language sources (TODO: add these) -# * Directory stuff (TODO(ring): remove these): -# * crypto/directory_posix.c -# * crypto/directory_win.c -# * Platform-specific threading (merged in below) -# * crypto/thread_none.c -# * crypto/thread_pthread.c -# * crypto/thread_win.c -# * Other Windows-specific files: -# * crypto/rand/windows.c -# * crypto/test/* RING_SRCS = $(addprefix $(RING_PREFIX), \ crypto/aes/aes.c \ crypto/aes/mode_wrappers.c \ @@ -158,33 +145,60 @@ RING_x86_64_SRCS = $(addprefix $(RING_PREFIX), \ crypto/sha/asm/sha512-x86_64.pl \ $(NULL)) -RING_armv7_SRCS = $(addprefix $(RING_PREFIX), \ - crypto/aes/asm/aes-armv4.pl \ +RING_ARM_SHARED_SRCS = \ crypto/aes/asm/aesv8-armx.pl \ + crypto/cpu-arm-asm.S \ + $(NULL) + +RING_arm_SRCS = $(addprefix $(RING_PREFIX), \ + crypto/aes/asm/aes-armv4.pl \ crypto/aes/asm/bsaes-armv7.pl \ crypto/bn/asm/armv4-mont.pl \ crypto/modes/asm/ghash-armv4.pl \ - crypto/modes/asm/ghashv8-armx.pl \ crypto/sha/asm/sha1-armv4-large.pl \ crypto/sha/asm/sha256-armv4.pl \ crypto/sha/asm/sha512-armv4.pl \ + $(RING_ARM_SHARED_SRCS) \ $(NULL)) -RING_armv8_SRCS = $(addprefix $(RING_PREFIX), \ +# TODO +RING_CPPFLAGS += -D__ARM_MAX_ARCH__=7 + +RING_arm_SRCS += $(addprefix $(RING_PREFIX), \ + crypto/chacha/chacha_vec_arm.S \ + crypto/poly1305/poly1305_arm_asm.S \ + $(NULL)) + +RING_aarch64_SRCS = $(addprefix $(RING_PREFIX), \ + crypto/modes/asm/ghashv8-armx.pl \ crypto/sha/asm/sha1-armv8.pl \ + crypto/sha/asm/sha256-armv8.pl \ crypto/sha/asm/sha512-armv8.pl \ + $(RING_ARM_SHARED_SRCS) \ $(NULL)) -RING_SRCS += $(RING_$(TARGET_ARCH_BASE)_SRCS) - -# TODO: Allow the choice of crypto/thread_none.c instead. +ifeq ($(TARGET_SYS),none) +RING_THREAD_FLAGS += -DOPENSSL_TRUSTY=1 -DOPENSSL_NO_THREADS=1 +RING_SRCS += $(addprefix $(RING_PREFIX), crypto/thread_none.c) +else +RING_THREAD_FLAGS += -pthread RING_SRCS += $(addprefix $(RING_PREFIX), crypto/thread_pthread.c) +endif -RING_OBJS = $(addprefix $(OBJ_PREFIX), \ - $(patsubst %.c, %.o, \ - $(patsubst %.pl, %.o, \ - $(RING_SRCS))) \ - $(NULL)) +RING_ASM_OBJS = \ + $(addprefix $(OBJ_PREFIX), \ + $(patsubst %.pl, %.o, \ + $(patsubst %.S, %.o, $(RING_$(TARGET_ARCH_NORMAL)_SRCS)))) + +$(RING_ASM_OBJS): CPPFLAGS += -Icrypto + +RING_OBJS = $(addprefix $(OBJ_PREFIX), $(patsubst %.c, %.o, $(RING_SRCS))) + +ifeq ($(NO_ASM),) +RING_OBJS += $(RING_ASM_OBJS) +else +RING_CPPFLAGS += -DOPENSSL_NO_ASM=1 +endif RING_LIB = $(LIB_PREFIX)libring.a @@ -238,6 +252,9 @@ RING_TEST_MAIN_OBJS = $(addprefix $(OBJ_PREFIX), \ RING_TEST_EXES = $(RING_TEST_MAIN_OBJS:$(OBJ_PREFIX)%.o=$(EXE_PREFIX)%) +ifeq ($(TARGET_SYS),none) +$(RING_TEST_EXES): LDLIBS += --specs=rdimon.specs +endif $(RING_TEST_EXES): LDLIBS += $(RING_LDLIBS) $(RING_TEST_EXES): $(EXE_PREFIX)% : \ $(OBJ_PREFIX)%.o \ @@ -290,7 +307,7 @@ endif PERLASM_x86_ARGS = $(PERLASM_FLAVOUR) -fPIC -DOPENSSL_IA32_SSE2 PERLASM_x86_64_ARGS = $(PERLASM_FLAVOUR) -PERLASM_ARGS = $(PERLASM_$(TARGET_ARCH_BASE)_ARGS) +PERLASM_ARGS = $(PERLASM_$(TARGET_ARCH_NORMAL)_ARGS) $(OBJ_PREFIX)%.S: %.pl $(PERLASM_LIB_SRCS) ${PERL_EXECUTABLE} $< $(PERLASM_ARGS) > $@ diff --git a/mk/top_of_makefile.mk b/mk/top_of_makefile.mk index d12127970..8627d1f98 100644 --- a/mk/top_of_makefile.mk +++ b/mk/top_of_makefile.mk @@ -24,26 +24,58 @@ endef $(error TARGET must be of the form \ []---.$(NEWLINE)\ \ - Linux x86 example: TARGET=x86-pc-linux-gnu $(NEWLINE)\ + Linux x86 example: TARGET=i586-pc-linux-gnu $(NEWLINE)\ Mac OS X x64 example: TARGET=x86_64-apple-darwin-macho) $(NEWLINE)\ \ - NOTE: Use "x86" instead of "i386", "i586", "i686", etc.) + NOTE: Use "i586" instead of "x86", etc.) endif TARGET_ARCH_BASE = $(word 1,$(TARGET_WORDS)) +TARGET_ARCH_NORMAL = \ + $(strip $(if $(findstring arm, $(TARGET_ARCH_BASE)),arm, \ + $(if $(filter i386 i486 i586 i686, \ + $(TARGET_ARCH_BASE)),x86,$(TARGET_ARCH_BASE)))) + TARGET_VENDOR = $(word 2,$(TARGET_WORDS)) TARGET_SYS = $(word 3,$(TARGET_WORDS)) TARGET_ABI = $(word 4,$(TARGET_WORDS)) -# Although it isn't documented, GNU Make passes $(TARGET_ARCH) in its implicit -# rules. -ifeq ($(TARGET_ARCH_BASE),x86) -TARGET_ARCH ?= -m32 -else ifeq ($(TARGET_ARCH_BASE),x86_64) -TARGET_ARCH ?= -m64 -else -$(error You must specify TARGET_ARCH_BASE as one of {x86,x86_64}) +# XXX: Apple's toolchain fails to link when the |-target| arch is "x86_64", +# so just skip -target on Darwin for now. +ifneq ($(TARGET_ARCH_NORMAL)-$(findstring darwin,$(TARGET_SYS)),x86_64-darwin) +ifeq ($(findstring clang,$(CC)),clang) +DEFAULT_TARGET_ARCH = -target "$(TARGET)" endif +endif + +ifeq ($(TARGET_ARCH_NORMAL),x86) +MARCH = pentium +MINSTR = 32 +else ifeq ($(TARGET_ARCH_NORMAL),x86_64) +MARCH = x86-64 +MINSTR = 64 +else +MARCH = $(subst _,-,$(TARGET_ARCH_BASE)) +endif + +ifeq ($(TARGET_ABI),eabi) +MABI = aapcs +endif + +# Cortex-M0, Cortex-M0+, Cortex-M1: armv6_m +# Cortex-M3: armv7_m +# Cortex-M4, Cortex-M7: armv7e_m +ifeq ($(filter-out armv6_m armv7_m armv7e_m,$(TARGET_ARCH_BASE)),) +MINSTR = thumb +endif + +# Although it isn't mentioned in the GNU Make manual, GNU Make passes +# $(TARGET_ARCH) in its implicit rules. +TARGET_ARCH += $(if $(MCPU),-mcpu=$(MCPU)) \ + $(if $(MARCH),-march=$(MARCH)) \ + $(if $(MABI),-mabi=$(MABI)) \ + $(if $(MINSTR),-m$(MINSTR)) \ + $(NULL) ifeq ($(CC),) $(error You must specify CC) @@ -121,8 +153,6 @@ endif CPPFLAGS += \ -pedantic -pedantic-errors \ \ - -fstack-protector \ - \ -Wall -Werror \ -Wextra \ \ @@ -138,6 +168,14 @@ CPPFLAGS += \ -Wwrite-strings \ $(NULL) +# XXX: Stack protector causes linking failures for armv7-*-none-eabi and +# it's use seems questionable for that kind of target anyway. +# The launchpad.net arm-none-eabi-gcc toolchain (at least) uses -fshort-enums. +ifneq ($(TARGET_SYS),none) +CPPFLAGS += -fstack-protector +endif + + # TODO (not in clang): # -Wjump-misses-init # -Wold-style-declaration \ diff --git a/mk/update-travis-yml.py b/mk/update-travis-yml.py index 3d4130405..acefa249e 100644 --- a/mk/update-travis-yml.py +++ b/mk/update-travis-yml.py @@ -64,13 +64,13 @@ oss = [ targets = { "osx" : [ ("x86_64-apple-darwin-macho", ""), - ("x86-apple-darwin-macho", ""), + ("i586-apple-darwin-macho", ""), ], "linux" : [ ("x86_64-pc-linux-gnu", ""), - ("x86-pc-linux-gnu", ""), - ("x86_64-pc-linux-gnu", "1"), - ("x86-pc-linux-gnu", "1"), + ("i586-pc-linux-gnu", ""), + ("x86_64-pc-linux-gnu", "NO_ASM=1"), + ("i586-pc-linux-gnu", "NO_ASM=1"), ], } @@ -88,7 +88,7 @@ def format_entries(): # XXX: 32-bit GCC 4.9 does not work because Travis does # not have g++-4.9-multilib whitelisted for use. if not (compiler == "gcc-4.9" and - target == "x86-pc-linux-gnu")]) + target == "i586-pc-linux-gnu")]) # Set |USE_CC| and |USE_CXX| instead of |CC| and |CXX| since Travis sets |CC| # and |CXX| to its default values *after* processing the |env:| directive here. @@ -151,7 +151,7 @@ def get_linux_packages_to_install(compiler, arch): else: raise ValueError("unexpected compiler: %s" % compiler) - if arch == "x86": + if arch == "i586": if compiler.startswith("clang-"): packages += ["libc6-dev-i386", "gcc-multilib",