mirror of
https://github.com/travitch/whole-program-llvm
synced 2026-06-08 17:53:44 +00:00
issue #115 over at travitch's place.
This commit is contained in:
@@ -19,7 +19,7 @@ e:
|
||||
|
||||
|
||||
one:
|
||||
${CC} foo.c bar.c baz.c main.c -o main
|
||||
${CC} -pthread foo.c bar.c baz.c main.c -o main
|
||||
|
||||
two:
|
||||
${CC} foo.c bar.c baz.c main.c -c
|
||||
@@ -37,6 +37,8 @@ mix_e:
|
||||
${CC} -emit-llvm foo.c bar.c -c
|
||||
${CC} foo.bc bar.bc baz.c main.c -o main
|
||||
|
||||
threads:
|
||||
${CXX} -pthread test1.cpp test2.cpp -o main
|
||||
|
||||
objects:
|
||||
${CC} foo.c -c
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// test1.cpp
|
||||
#include "test1.h"
|
||||
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
int glb_ext = 1;
|
||||
|
||||
void lock() {
|
||||
pthread_mutex_lock(&m);
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
pthread_mutex_unlock(&m);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// test1.h
|
||||
#ifndef TEST1_H_
|
||||
#define TEST1_H_
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int glb_ext;
|
||||
extern pthread_mutex_t m;
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// test2.cpp
|
||||
#include "test1.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int glb_test;
|
||||
|
||||
void *Thread1(void* x) {
|
||||
lock();
|
||||
glb_test++;
|
||||
unlock();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *Thread2(void* x) {
|
||||
lock();
|
||||
glb_test++;
|
||||
unlock();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int main() {
|
||||
pthread_t t[2];
|
||||
pthread_create(&t[0], nullptr, Thread1, nullptr);
|
||||
pthread_create(&t[1], nullptr, Thread1, nullptr);
|
||||
pthread_join(t[0], nullptr);
|
||||
pthread_join(t[1], nullptr);
|
||||
return 0;
|
||||
}
|
||||
@@ -63,7 +63,8 @@ class ArgumentListFilter:
|
||||
'-no-integrated-as' : (0, ArgumentListFilter.compileUnaryCallback),
|
||||
'-integrated-as' : (0, ArgumentListFilter.compileUnaryCallback),
|
||||
#iam: gcc uses this in both compile and link, but clang only in compile
|
||||
'-pthread' : (0, ArgumentListFilter.compileUnaryCallback),
|
||||
#iam: actually on linux it looks to be both
|
||||
'-pthread' : (0, ArgumentListFilter.compileLinkUnaryCallback),
|
||||
# I think this is a compiler search path flag. It is
|
||||
# clang only, so I don't think it counts as a separate CPP
|
||||
# flag. Android uses this flag with its clang builds.
|
||||
|
||||
Reference in New Issue
Block a user