Skip to content

multiple definition of `__adddf3' when removing clib and adding CONFIG_BT_ENABLE #51

Open
@PocketPi

Description

@PocketPi

I tried to integrate a rust module in my c based project based on this example.

I got a whole lot of multiple definition errors in low level function calls.:

[100%] Linking CXX executable esp32-hello-rust.elf
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__adddf3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__adddf3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_addsubdf3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:100: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__floatunsidf':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__floatunsidf'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_floatsidf.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:2143: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__floatsidf':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__floatsidf'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_floatsidf.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:2154: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__fixunsdfsi':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__fixunsdfsi'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_fixunsdfsi.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:1999: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__fixdfsi':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__fixdfsi'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_fixdfsi.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:1872: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__divsf3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__divsf3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_divsf3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-sf.S:912: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__divdf3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__divdf3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_divdf3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:1421: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__extendsfdf2':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__extendsfdf2'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_extendsfdf2.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:2402: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__muldf3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__muldf3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_muldf3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:763: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__subdf3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__subdf3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_addsubdf3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/config/xtensa/ieee754-df.S:362: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__divdi3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__divdi3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_divdi3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/libgcc2.c:1212: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__moddi3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__moddi3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_moddi3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/libgcc2.c:1236: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__udivdi3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__udivdi3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_udivdi3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/libgcc2.c:1299: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/rustlib/target/xtensa-esp32-espidf/release/librustlib.a(compiler_builtins-8efe5aa9d251e5ee.compiler_builtins.69fa668e5acca28c-cgu.1.rcgu.o): in function `__umoddi3':
/home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.105/src/macros.rs:499: multiple definition of `__umoddi3'; /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/libgcc.a(_umoddi3.o):/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/gcc/libgcc/libgcc2.c:1287: first defined here
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: warning: /home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/esp32/no-rtti/crtn.o: missing .note.GNU-stack section implies executable stack
/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/esp32-hello-rust.elf.dir/build.make:490: esp32-hello-rust.elf] Error 1
make[1]: *** [CMakeFiles/Makefile2:2084: CMakeFiles/esp32-hello-rust.elf.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
make failed with exit code 2, output of the command is in the /home/peter/data/code/rust-esp32-example/build/log/idf_py_stderr_output_3024475 and /home/peter/data/code/rust-esp32-example/build/log/idf_py_stdout_output_3024475

I spend some time debugging and in the end found the combination that made the problems.

removing clib as i do not need to call c from my rust code and enabling bt as i need that in my project. See diff below:

peter:~/data/code/rust-esp32-example(main)$ git diff
diff --git a/components/rustlib/CMakeLists.txt b/components/rustlib/CMakeLists.txt
index 4100cff..53fd0dc 100644
--- a/components/rustlib/CMakeLists.txt
+++ b/components/rustlib/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(RUST_DEPS "clib")
+#set(RUST_DEPS "clib")
 
 idf_component_register(
     SRCS "placeholder.c"
diff --git a/components/rustlib/src/lib.rs b/components/rustlib/src/lib.rs
index c10bbbc..195c1cb 100644
--- a/components/rustlib/src/lib.rs
+++ b/components/rustlib/src/lib.rs
@@ -33,19 +33,19 @@ pub mod sys {
 
 #[no_mangle]
 pub extern "C" fn add_in_rust(x: i32, y: i32) -> i32 {
-    unsafe {
-        sys::validate_param_in_c(0, x);
-        sys::validate_param_in_c(1, y);
-    }
+    // unsafe {
+    //     sys::validate_param_in_c(0, x);
+    //     sys::validate_param_in_c(1, y);
+    // }
     x + y
 }
 
 #[no_mangle]
 pub extern "C" fn add_in_rust_inline_asm(mut x: i32, y: i32) -> i32 {
-    unsafe {
-        sys::validate_param_in_c(0, x);
-        sys::validate_param_in_c(1, y);
-    }
+    // unsafe {
+    //     sys::validate_param_in_c(0, x);
+    //     sys::validate_param_in_c(1, y);
+    // }
     unsafe {
         // more detail available: https://doc.rust-lang.org/beta/unstable-book/library-features/asm.html
         asm!("add {0}, {0}, {1}", inout(reg) x, in(reg) y);
diff --git a/sdkconfig.defaults b/sdkconfig.defaults
index e69de29..032247b 100644
--- a/sdkconfig.defaults
+++ b/sdkconfig.defaults
@@ -0,0 +1 @@
+CONFIG_BT_ENABLED=y
peter:~/data/code/rust-esp32-example(main)$ 

Can you help me understand if im doing something wrong or if there is a problem in the esp code somewhere

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions