Search code examples
cassemblygnu-assemblerxtensa

"Error: attempt to move .org backwards" using Xtensa XCC, GCC works fine


Here is a minimal reproducible example:

/*
 * Example for Xtensa xt-xcc compiler "error: attempt to move .org backwards".
 */

struct k_dict
{
    char *m_name_dict;
    char *p_name_dict;
    union
    {
        float f_value;
        int i_value;
        char* s_value;
    };
};

struct k_mode
{
    const char*  m_name;
          int    p_number;
    const struct k_dict *p;
    const struct k_dict pars[];
};

struct k_dict P1[] =
{
    {.m_name_dict="M1", .p_name_dict="P1", .s_value="string"},
    {.m_name_dict="M2", .p_name_dict="P2", .i_value=5       },
    {.m_name_dict="M3", .p_name_dict="P3", .f_value=48.0    }
};

struct k_mode mode_default =
{
    .m_name   = "default",
    .p_number = 1,
    .p        = P1,
    .pars =
    {
        {.m_name_dict = "m", .p_name_dict="p", .s_value="s"}
    }
};


int main( int argc, char **argv )
{
    return 0;
}

Compiling this using Tensilica Xtensa xt-xcc compiler gives assembler error:

"xt-xcc" -c -g -O0 -std=c11 -fmessage-length=0 -DPROC_hifi3_tv_car_5 -DCONFIG_hifi3_tv_car_5 --xtensa-system=hifi3_tv_car_5/config --xtensa-core=hifi3_tv_car_5 --xtensa-params= "\"HelloWorld/main.c\"" -o "\"HelloWorld/bin/hifi3_tv_car_5/Debug/main.o\"" 
/Temp/cc0s#6c7c.a32040: Assembler messages:
/Temp/cc0s#6c7c.a32040:39: Error: attempt to move .org backwards
xt-xcc ERROR: XtensaTools/bin/xt-as.exe returned non-zero status 1   

Where could this come from?

Note: GCC works fine.


Solution

  • Seems like C11 is not supported by xt-xcc, even there is no warning reported by the compiler when the -std=c11 flag is added.

    From the Xtensa manual: "Support for the C11 standard can be enabled with the -std=c11 option only with the Clang front end. (...) Starting with the RG-2017.7 release, XCC includes an alternative compiler front end based on Clang version 3.4 from the LLVM project. In future versions, the Clang front end will replace GCC. The Clang front end is selected by using the -clang compiler option."

    Using Clang the above code compiles fine.