Skip to content

Commit

Permalink
cc: add powerpc support
Browse files Browse the repository at this point in the history
Basic support for building on powerpc. Tested on ppc64le.

Signed-off-by: Naveen N. Rao <[email protected]>
  • Loading branch information
rnav committed May 2, 2016
1 parent 8216464 commit 0006ad1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/cc/frontends/clang/loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/cc/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@
// 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
Expand Down

0 comments on commit 0006ad1

Please sign in to comment.