cc: add powerpc support
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Fri, 29 Apr 2016 11:12:58 +0000 (16:42 +0530)
committerNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Mon, 2 May 2016 08:40:32 +0000 (14:10 +0530)
Basic support for building on powerpc. Tested on ppc64le.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
src/cc/CMakeLists.txt
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/loader.cc
src/cc/libbpf.c

index 93041ae..c905e3d 100644 (file)
@@ -44,7 +44,7 @@ set_target_properties(bcc-static PROPERTIES OUTPUT_NAME bcc)
 # BPF is still experimental otherwise it should be available
 #llvm_map_components_to_libnames(llvm_libs bpf mcjit irreader passes)
 llvm_map_components_to_libnames(llvm_libs bitwriter bpfcodegen irreader linker
-  mcjit objcarcopts option passes x86codegen)
+  mcjit objcarcopts option passes nativecodegen)
 llvm_expand_dependencies(expanded_libs ${llvm_libs})
 
 # order is important
index 852abc0..d630e5f 100644 (file)
@@ -35,8 +35,14 @@ namespace ebpf {
 const char *calling_conv_regs_x86[] = {
   "di", "si", "dx", "cx", "r8", "r9"
 };
+const char *calling_conv_regs_ppc[] = {"gpr[3]", "gpr[4]", "gpr[5]",
+                                       "gpr[6]", "gpr[7]", "gpr[8]"};
 // todo: support more archs
+#if defined(__powerpc__)
+const char **calling_conv_regs = calling_conv_regs_ppc;
+#else
 const char **calling_conv_regs = calling_conv_regs_x86;
+#endif
 
 using std::map;
 using std::set;
index 41c0649..aa929b8 100644 (file)
@@ -128,7 +128,11 @@ int ClangLoader::parse(unique_ptr<llvm::Module> *mod, unique_ptr<vector<TableDes
   DiagnosticsEngine diags(DiagID, &*diag_opts, diag_client);
 
   // set up the command line argument wrapper
+#if defined(__powerpc64__)
+  driver::Driver drv("", "ppc64le-unknown-linux-gnu", diags);
+#else
   driver::Driver drv("", "x86_64-unknown-linux-gnu", diags);
+#endif
   drv.setTitle("bcc-clang-driver");
   drv.setCheckInputsExist(false);
 
index 62bfea1..c038fd4 100644 (file)
 // TODO: remove these defines when linux-libc-dev exports them properly
 
 #ifndef __NR_bpf
+#if defined(__powerpc64__)
+#define __NR_bpf 361
+#else
 #define __NR_bpf 321
 #endif
+#endif
 
 #ifndef SO_ATTACH_BPF
 #define SO_ATTACH_BPF 50