I want to launch assembler from the gcc command in Gradle

I want to launch my assembler by using the invocation for the C compiler.

For example, sparc-rtems-gcc -x assembler-with-cpp my_asm.s -o my_asm.o

However, I am unable to do this using Gradle. It by default adds the -x assembler option whenever I invoke sparc-rtems-gcc

How should my build.gradle look to launch it the way I want. Currently, I am not really sure what arguments to pass. Below is my current build.gradle

// build.gradle

apply plugin: ‘assembler’

model {

toolChains {
    gcc(Gcc) {
        path "/opt/rtems/version_x/bin"
        eachPlatform {
            assembler.executable = "sparc-rtems-gcc"
        assembler.withArguments { args ->

The other arguments to my assembler I have them under binaries using the assembler.args