spectre-attack icon indicating copy to clipboard operation
spectre-attack copied to clipboard

how to compile the code in MacOS?

Open songtianyi opened this issue 6 years ago • 3 comments

gcc output

spectre.c:83:21: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
                        time1 = __rdtscp(&junk); /* READ TIMER */
                                         ^~~~~
/Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.1.0/include/ia32intrin.h:71:24: note: passing argument to parameter '__A' here
__rdtscp(unsigned int *__A) {
                       ^
spectre.c:85:21: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
                        time2 = __rdtscp(&junk) - time1; /* READ TIMER & COMPUTE ELAPSED TIME */
                                         ^~~~~
/Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.1.0/include/ia32intrin.h:71:24: note: passing argument to parameter '__A' here
__rdtscp(unsigned int *__A) {
                       ^

songtianyi avatar Jan 05 '18 04:01 songtianyi

ignore warning

./a.out

cch123 avatar Jan 05 '18 10:01 cch123

Try this implementation with pthread.h Should work on macos https://gist.github.com/Eugnis/3ba3f048988e7be76737ab87da64bb26 Compile on MacOS clang -O0 spectre-thread.c -o spectre && ./spectre

Eugnis avatar Jan 05 '18 12:01 Eugnis

I found it to work today on MacOS with no modifications.

douglasheld avatar Jan 09 '18 21:01 douglasheld