Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Compiling the Linux kernel with ICC 13

One_C_
Beginner
578 Views

Hi, I am trying to compile the Linux kernel with ICC 13.1.2, GCC 4.7.3 on Ubuntu 13.04. While I had some limited succes with kernel 2.6.32 after some code tweaks, I am totally stuck with 3.8.0.23. I get an error in linux-3.8.0/arch/x86/include/asm/cpufeature.h(349): error: invalid constant in assembly language instruction

asm goto("1: jmp %l[t_no]\n"
^

The problematic code snippet is:

[cpp]asm goto("1: jmp %l[t_no]\n"
"2:\n"
".section .altinstructions,\"a\"\n"
" .long 1b - .\n"
" .long 0\n" /* no replacement */
" .word %P0\n" /* feature bit */
" .byte 2b - 1b\n" /* source len */
" .byte 0\n" /* replacement len */
".previous\n"
/* skipping size check since replacement size = 0 */
: : "i" (bit) : : t_no);
return true;
t_no:
return false;[/cpp]

After some Google research it turns out that this syntacs is not recognized by the Intel Compiler and some tweaks have to be done. I tryed all possible combinations with __asm __asm__ volatile asm and so on but nothing helps. How is this piece supposed to be rewritten in order to compile?

By the way, attached is my wrapper script for the compiler. I don't know how good it is so any comments on it are welcome too.

0 Kudos
3 Replies
One_C_
Beginner
578 Views

For some reason the file with the wrapper script wasn't attached. Here is its content:

[bash]

#!/bin/sh

ARGS=$@
ICCARGS="-wd21,47,64,69,175,411,412,413,592,1079,1366,1549,2621,10121,10159,11010 -fasm-blocks"

# For loop to change options of icc
for ARG in $@
do
case $ARG in
-Wno-pointer-sign)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-frename-registers)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-fno-unit-at-a-time)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-fno-delete-null-pointer-checks)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-msoft-float)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-mfloat-abi)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-gstabs)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-fconserve-stack)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-funit-at-a-time)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-Wframe-larger-than=1024)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-march=i386)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-mpreferred-stack-boundary=2)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

-mpreferred-stack-boundary=3)
echo "Skipping $ARG" >> $HOME/src/log.txt
;;

* )
ICCARGS="$ICCARGS $ARG"
;;
esac
done

icc $ICCARGS

exit $?

[/bash]

0 Kudos
Melanie_B_Intel
Employee
578 Views

We have a defect report about asm goto in our bugs database, 230499

Meanwhile, I checked the code, and there's a way to program around the problem.  If you check that header file, cpufeature.h, it has 2 ways to provide the implementation of __static_cpu_has.  The "new" way uses asm goto.  Check that conditional compilation and force it to use the path that doesn't involve asm goto (i.e. you'll need to modify the #if).

#if __GNUC__ >= 4
/*
* Static testing of CPU features. Used the same as boot_cpu_has().
* These are only valid after alternatives have run, but will statically
* patch the target code for additional performance.
*
*/
static __always_inline __pure bool __static_cpu_has(u16 bit)
{
#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
asm goto("1: jmp %l[t_no]\n"

0 Kudos
One_C_
Beginner
578 Views

Thanks! That solves the problem. I tweaked the if statement so that the first way of determining __static_cpu_has(u16 bit) which involves goto is skipped and the second one used.

0 Kudos
Reply