GithubHelp home page GithubHelp logo

aurix-rust-release-build-issue-example's Introduction

This is an example of a crate failing to build only when --release is enabled.

Build in debug mode, everything works as expected:

cargo +tricore b --target=tc162-htc-none

Build in release mode, the build fails.

cargo +tricore b --target=tc162-htc-none --release

This is the error:

error: __INTERRUPT_HANDLER_2 changed binding to STB_GLOBAL

error: symbol '__INTERRUPT_HANDLER_2' is already defined

error: Crt0PreInit changed binding to STB_GLOBAL

error: symbol 'Crt0PreInit' is already defined

error: Crt0PostInit changed binding to STB_GLOBAL

error: symbol 'Crt0PostInit' is already defined

error: could not compile `can` (bin "can") due to 6 previous errors

To fix this:

error: __INTERRUPT_HANDLER_2 changed binding to STB_GLOBAL

error: symbol '__INTERRUPT_HANDLER_2' is already defined

I neede to remove __INTERRUPT_HANDLER_2 from the generated interrupt handlers at the end of main.rs:

diff --git a/src/main.rs b/src/main.rs
index 08ffd35..4020409 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -725,7 +725,8 @@ mod runtime {
         "   .endif",
         ".endm ",
         ".pushsection .text.default_int_handler, \"ax\",@progbits",
-        "interrupt_hnd 0, 15",
+        "interrupt_hnd 0, 1",
+        "interrupt_hnd 3, 15",
         "interrupt_hnd 16, 32",
         "   ret",
         ".popsection",

To fix this:

error: Crt0PreInit changed binding to STB_GLOBAL

error: symbol 'Crt0PreInit' is already defined

error: Crt0PostInit changed binding to STB_GLOBAL

error: symbol 'Crt0PostInit' is already defined

error: could not compile `can` (bin "can") due to 6 previous errors

I needed to remove these two functions:

    // FUNCTION: Crt0PreInit
    // User hook before 'C' runtime initialization. Empty routine in case of crt0 startup code.
    global_asm!(
        ".weak Crt0PreInit",
        ".type Crt0PreInit, %function",
        "Crt0PreInit:",
        "ret",
    );

    // FUNCTION: Crt0PostInit
    // User hook after 'C' runtime initialization. Empty routine in case of crt0 startup code.
    global_asm!(
        ".weak Crt0PostInit",
        ".type Crt0PostInit, %function",
        "Crt0PostInit:",
        "ret",
    );

It seems that the ".weak" directive is not working when building with --release flag.

The three functions __INTERRUPT_HANDLER_2 Crt0PostInit and Crt0PreInit are defined in the above code. I expect that the weak versions of these functions defined in the inline assembly should be ignored when a strong definition exists.

aurix-rust-release-build-issue-example's People

Contributors

alepez avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.