Skip to contentSkip to conversation

tools: testing: define the _GNU_SOURCE macro

PATCH In review Muhammad Falak R Wani 2 participants 4 messages May 13, 2016 – May 16, 2016 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: testing: define the _GNU_SOURCE macro

Add the macro _GNU_SOURCE, so that compilation does not terminate.

---
 tools/testing/selftests/intel_pstate/run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/intel_pstate/run.sh +1 -1
index bdaf37e..7868c10 100755
@@ -32,7 +32,7 @@ EVALUATE_ONLY=0
 max_cpus=$(($(nproc)-1))
 
 # compile programs
-gcc -o aperf aperf.c -lm
+gcc aperf.c -Wall -D_GNU_SOURCE -o aperf  -lm
 [ $? -ne 0 ] && echo "Problem compiling aperf.c." && exit 1
 gcc -o msr msr.c -lm
 [ $? -ne 0 ] && echo "Problem compiling msr.c." && exit 1
Signature · 1 line
1.9.1
#1 lore raw
Quoted 1 line · Muhammad Falak R Wani

Add the macro _GNU_SOURCE, so that compilation does not terminate.

What error are you seeing? Could you please send the compilation error log.

thanks,
-- Shuah

Quoted 20 lines
---
 tools/testing/selftests/intel_pstate/run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/intel_pstate/run.sh +1 -1
index bdaf37e..7868c10 100755
@@ -32,7 +32,7 @@ EVALUATE_ONLY=0
 max_cpus=$(($(nproc)-1))
 
 # compile programs
-gcc -o aperf aperf.c -lm
+gcc aperf.c -Wall -D_GNU_SOURCE -o aperf  -lm
 [ $? -ne 0 ] && echo "Problem compiling aperf.c." && exit 1
 gcc -o msr msr.c -lm
 [ $? -ne 0 ] && echo "Problem compiling msr.c." && exit 1
#2 lore raw
Quoted 21 lines · Shuah Khan
Quoted 1 line · Muhammad Falak R Wani

Add the macro _GNU_SOURCE, so that compilation does not terminate.

What error are you seeing? Could you please send the compilation error log.

thanks,
-- Shuah

Quoted 13 lines
---
 tools/testing/selftests/intel_pstate/run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/intel_pstate/run.sh +0 -0
index bdaf37e..7868c10 100755
@@ -32,7 +32,7 @@ EVALUATE_ONLY=0
 max_cpus=$(($(nproc)-1))
 
Quoted 8 lines

tools/testing/selftests/intel_pstate/run.sh EVALUATE_ONLY=0 · line 38

Quoted 7 lines
tools/testing/selftests/intel_pstate/run.sh +1 -1
 # compile programs
-gcc -o aperf aperf.c -lm
+gcc aperf.c -Wall -D_GNU_SOURCE -o aperf  -lm
 [ $? -ne 0 ] && echo "Problem compiling aperf.c." && exit 1
 gcc -o msr msr.c -lm
 [ $? -ne 0 ] && echo "Problem compiling msr.c." && exit 1

When I try to run "run.sh", I get the following linker error
------

mfrw@kp:~/kp/tools/testing/selftests/intel_pstate$ ./run.sh 
/tmp/ccVLsFVk.o: In function `main':
aperf.c:(.text+0x12e): undefined reference to `CPU_ZERO'
aperf.c:(.text+0x14a): undefined reference to `CPU_SET'
collect2: error: ld returned 1 exit status
Problem compiling aperf.c.

------

The root cause of the problem is, we haven't defined a macro _GNU_SOURCE, which is necessary for CPU_ZERO, CPU_SET. After adding the appropriate macro, it compiles without any error.

#3 lore raw
Quoted 9 lines · Muhammad Falak R Wani
Quoted 8 lines · Shuah Khan
Quoted 1 line · Muhammad Falak R Wani

Add the macro _GNU_SOURCE, so that compilation does not terminate.

What error are you seeing? Could you please send the compilation error log.

thanks,
-- Shuah

Applied to linux-kselftest next fgor 4.7-rc1 with fixed up changelog to include why the change is needed.

thanks,
-- Shuah