Questions how to add a target spec for RTEMS cross-compilation

Dear Rust community,

My goal is to add a tier 3 target option which compiles Rust code for the RTEMS real-time OS (see So far I managed to add a target spec which allows compiling and linking an RTEMS binary, with !#[no_std] set for a certain Board Support Package (BSP). I also read through the development process for adding new targets via Github PRs.

Before I start the PR process with the tier 3 template, I would just like to ask a few question to finish the first version.

The standard RTEMS cross-compiler (i.e. arm-rtems6-gcc) is only built once, but can generate the object code for many different BSPs with different architecture flags. The processor dependent ABI flags for each BSP are stored in corresponding a pkg-config file.

In my example spec I just hardcoded the BSP specific flags for now, but for a useful setup I would like to have something like the following workflow:

  • Set the name of the concrete BSP via an environment variable (e.g. RTEMS_BSP).
  • Start the compilation of the user application with cargo
  • Read the pkg-config information for the BSP
  • Add the flags for -march, -mfloat-abi, etc. and the BSP include paths to the target options from this information
  • Compile the user application

Is this a viable option? I guess this would mean that the core/std library would need to be build with the user program (before the architecture flags are not known)? Is it possible to read pkg-config information from inside the spec file? Reading the environment variable should be possible via std::env, but the pkg-config crate looks like an external dependency.

Any other suggestions would also be greatly appreciated.

Cheers, Jan

PS: I also wasn't sure which communication channel would be the right one. Feel free to point me to a more appropriate channel.

If two options are abi incompatible, they should have different targets to ensure mixing libraries with different abi's will result in an error. Target specs shouldn't read any external things as otherwise you risk having incompatible options for different rustc invocations and it generally makes cross-compiling harder.

Thanks, so if I have a board support package which requires these flags:

CPU_CFLAGS = -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9

Then I would create a target spec armv7-a-rtems6-eabihf (becuase of -march and -mfloat-abi) and the other options would be something to add via cargo at compile time of the user application?

I think so.

Thanks. I will check how to do the cargo side of things.