Skip to content

Commit 5d980a3

Browse files
committed
CMakeLists,rust: fix compilation error
With the symbols present, this happened: ``` /usr/local/bin/arm-none-eabi-objcopy: not stripping symbol `memcpy' because it is named in a relocation /usr/local/bin/arm-none-eabi-objcopy: not stripping symbol `memmove' because it is named in a relocation /usr/local/bin/arm-none-eabi-objcopy: not stripping symbol `memset' because it is named in a relocation ``` Seems like in the updated Rust toolchain, the symbols are correctly referenced and no workaround is needed. In return, some other symbols now seem to clash, but only in device-tests.
1 parent 3165d5a commit 5d980a3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2015-2016 Lucas Betschart, Douglas J. Bakkum
22
# Copyright 2019 Shift Cryptosecurity AG
3+
# Copyright 2020 Shift Crypto AG
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
56
# you may not use this file except in compliance with the License.
@@ -449,8 +450,12 @@ foreach(type ${RUST_LIBS})
449450
RUSTC_BOOTSTRAP=1
450451
${CARGO} build --manifest-path ${LIBBITBOX02_RUST_SOURCE_DIR}/Cargo.toml --features target-${type} --target-dir ${RUST_BINARY_DIR} ${RUST_CARGO_FLAG} ${RUST_TARGET_ARCH_ARG}
451452
# Rust packages stdlib functions which we must remove/weaken on the arm target
453+
# Currently the removed symbols only clash in device-tests for some reason. Without this command, compiling device tests would result in errors like:
454+
# Linking C executable ../../bin/fw_test_usb_cmd_process.elf
455+
# /usr/local/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: /usr/local/bin/../lib/gcc/arm-none-eabi/8.2.1/thumb/v7e-m+fp/softfp/libgcc.a(_arm_addsubdf3.o): in function `__aeabi_dsub':
456+
# (.text+0x8): multiple definition of `__aeabi_dsub'; ../../lib/libfirmware_rust_c.a(compiler_builtins-5829be534503bd8e.compiler_builtins.cthmhl66-cgu.175.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.27/src/macros.rs:226: first defined here
452457
COMMAND
453-
if test "x${RUST_TARGET_ARCH}" = "xthumbv7em-none-eabi" \; then ${CMAKE_OBJCOPY} -N memset -N memcpy -N memmove -W memcmp ${lib} \; fi
458+
if test "x${RUST_TARGET_ARCH}" = "xthumbv7em-none-eabi" \; then ${CMAKE_OBJCOPY} -W __aeabi_dsub -W __aeabi_dadd -W__aeabi_i2d -W __aeabi_f2d -W __aeabi_dmul ${lib} \; fi
454459
COMMAND
455460
${CMAKE_COMMAND} -E copy ${lib} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${type}_rust_c.a
456461
BYPRODUCTS

0 commit comments

Comments
 (0)