Skip to content

Commit 7726e93

Browse files
authored
adds omake as an optional compilation backend (#1039)
* fixes library dependencies The OMake plugin is not propagating the transitive closure of dependencies, so we need to specify our dependencies explicitly and not depend on dependencies induced by existing dependencies. * adds OMakefiles They describe the system and should be committed. Unfortunately, with OASIS they mostly contain the boilerplate code, but some of the actually contains the necessary flags. * cleans up the main Makefile * updates gitignore to ignore files produced by OMake * adds a missing header to disasm * adds the new build_plugins from the build-faster branch with some changes, e.g., we can't now look for `_build/plugins` * updates flags * implements configure-omake * don't forget the prefix * fixes the dependency name * updates missing dependencies * deletes unnecessary OMakefiles most of the OMakefiles are unmodified so we can just let oasis to generate them. So far, we have three OMakefiles that we want to have commited: the root one, that has some global options, and disasm with llvm OMakefiles, that include C++ and LLVM options which we just hardcode for now. * cleans up the OMakefile * ignore OMakefiles in general * runs oasis setup and setup.exe twice so that files generated by oasis setup could be seen by omake * cleans up the build_plugins tool to make codacy happy we switch from using bacticks to `$(...)`. * builds only directories in the plugins folder as there could be other files, which are not plugins * updates .merlin with _buildless paths since omake puts build artifacts directly into the source tree, we just need to reference to them without the _build folder. * fixes penultimated fix plugins weren't built at all.
1 parent ea8b315 commit 7726e93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+465
-109
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
src/bap
2+
src/bap-byteweight
3+
src/bap-mc
4+
src/baptop
5+
tools/bapbuild
6+
tools/bapbundle
7+
tools/postinstall
8+
run_*_tests
9+
run_tests
10+
11+
*.om
12+
*.omc
13+
*.omakedb*
14+
*.run
15+
*.opt
16+
17+
*.annot
18+
*.cmo
19+
*.cma
20+
*.cmi
21+
*.a
22+
*.o
23+
*.so
24+
*.cmx
25+
*.cmxs
26+
*.cmxa
27+
*.cmt
28+
*.cmti
129
*.ba*
230
*.clib
331
*.mldylib
@@ -45,3 +73,4 @@ _oasis
4573
/lib/bap_plugins/bap_plugins_config.ml
4674
bap_main_config.ml
4775
tools/postinstall.ml
76+
OMakefile

.merlin

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@ B _build/lib/regular
3939
B _build/lib/text_tags
4040
B _build/lib/knowledge
4141

42+
B lib/bap
43+
B lib/bap_main
44+
B lib/bap_recipe
45+
B lib/bap_abi
46+
B lib/bap_api
47+
B lib/bitvec
48+
B lib/bitvec_order
49+
B lib/bitvec_sexp
50+
B lib/bap_bundle
51+
B lib/bap_c
52+
B lib/bap_config
53+
B lib/bap_disasm
54+
B lib/bap_dwarf
55+
B lib/bap_elf
56+
B lib/bap_future
57+
B lib/bap_image
58+
B lib/bap_plugins
59+
B lib/bap_sema
60+
B lib/bap_types
61+
B lib/bap_core_theory
62+
B lib/graphlib
63+
B lib/monads
64+
B lib/ogre
65+
B lib/bap_primus
66+
B lib/bap_llvm
67+
B lib/regular
68+
B lib/text_tags
69+
B lib/knowledge
70+
71+
4272
S lib/bap
4373
S lib/bap_main
4474
S lib/bap_recipe

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ install-plugins:
2020
sh tools/build_plugins.sh
2121
if [ -f ./postinstall.native ]; then ./postinstall.native; fi
2222
if [ -f ./postinstall.byte ]; then ./postinstall.byte; fi
23+
if [ -f ./postinstall ]; then ./postinstall; fi
2324

2425
install-libs:
2526
$(SETUP) -install $(BAPINSTALLFLAGS)

OMakefile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Include OASIS library:
2+
3+
if $(not $(file-exists _oasis_lib.om))
4+
err. =
5+
extends $(Exception)
6+
message = $'Not set up. Run first: oasis setup'
7+
raise $(err)
8+
9+
if $(not $(file-exists setup.data))
10+
err. =
11+
extends $(Exception)
12+
message = $'Not configured. Run first: ocaml setup.ml -configure'
13+
raise $(err)
14+
15+
include _oasis_lib.om
16+
17+
# Include the configuration, i.e. the output of "ocaml setup.ml -configure".
18+
# The settings are written to a file setup.data. We need it in a different
19+
# format, and convert the setup here. Note that the variables from setup.data
20+
# are prefixed with "oasis_", e.g. "prefix" is made available as
21+
# $(oasis_prefix). At this point we also initialize a number of build-related
22+
# variables like BYTE_ENANBLED or OCAMLFLAGS.
23+
24+
.INCLUDE: _oasis_setup.om: setup.data
25+
OASIS_generate_setup()
26+
27+
# At this point you may fine-tune the configuration, and modify defaults:
28+
#
29+
# OCAML_LIB_MODULE_SUFFIXES += .ml (install also .ml files with libs)
30+
# OCAMLFINDFLAGS += -verbose (be verbose)
31+
# OCAMLFLAGS += -bin-annot (create .cmt/.cmti files)
32+
33+
OCAMLFLAGS_ANNOT = -annot -bin-annot
34+
OCAMLFLAGS += $(OCAMLFLAGS_ANNOT)
35+
OCAMLFLAGS += -opaque
36+
37+
# Until this point we allow to override variables via the command-line.
38+
# That means all initializations from above can be changed by omake arguments
39+
# here. E.g. invoke with "omake BYTE_ENABLED=false" to disable bytecode
40+
# builds.
41+
42+
DefineCommandVars()
43+
44+
# Global phonies: This declaration is visible in the whole build tree.
45+
46+
.PHONY: build doc install uninstall reinstall clean distclean
47+
.DEFAULT: build
48+
49+
# Define hierarchy (sets OASIS_SUBDIRS to the sub directories that are part
50+
# of the build):
51+
52+
include _oasis_hier.om
53+
54+
# Include these subdirectories into the build. Normally, you only name
55+
# direct subdirectories here. Also note that all definitions up to this
56+
# point are automatically passed down to the OMakefiles in the subdirectories.
57+
58+
.SUBDIRS: $(OASIS_SUBDIRS)
59+
60+
# Local phonies: This declaration is only visible in this directory.
61+
62+
.PHONY: build-here doc-here install-here uninstall-here reinstall-here pre-install-here clean-here distclean-here
63+
64+
include _oasis_build.om
65+
include _oasis_install.om
66+
67+
# These calls define the rules needed for "build", "install", etc.
68+
69+
DefineBuildRules()
70+
DefineInstallRules()
71+
72+
build-here: $(BUILD_TARGETS)
73+
doc-here: $(BUILD_DOC_TARGETS)
74+
install-here: $(INSTALL_TARGETS)
75+
uninstall-here: $(UNINSTALL_TARGETS)
76+
reinstall-here: $(REINSTALL_TARGETS)
77+
pre-install-here:
78+
79+
clean-here:
80+
rm -f $(OASIS_clean_list)
81+
rm -rf $(OASIS_rec_clean_list)
82+
section
83+
OASIS_rmdir($(OASIS_dir_clean_list))
84+
85+
distclean-here:
86+
rm -f $(OASIS_distclean_list)
87+
rm -rf $(OASIS_rec_distclean_list)
88+
section
89+
OASIS_rmdir($(OASIS_dir_distclean_list))
90+
91+
build: build-here
92+
doc: doc-here
93+
install: install-here
94+
uninstall: uninstall-here
95+
reinstall: reinstall-here
96+
clean: clean-here
97+
distclean: distclean-here

OMakeroot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# include the standard installed configuration file.
2+
include $(STDROOT)
3+
4+
# include the OMakefile in this directory.
5+
.SUBDIRS: .

configure-omake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
rm -f _oasis
4+
mv oasis/benchmarks oasis/benchmarks.backup
5+
mv oasis/piqi oasis/piqi.backup
6+
mv oasis/common oasis/common.backup
7+
cp oasis/common.omake oasis/common
8+
SECTIONS=`ocaml tools/oasis_sections.ml --sections --enable-everything`
9+
SETUPS=`ocaml tools/collect.ml setup.ml $SECTIONS`
10+
AB=`ocaml tools/collect.ml files.ab $SECTIONS`
11+
ocaml tools/cat.ml '"\n# $name\n"' -- $SECTIONS $AB _oasis
12+
ocaml tools/cat.ml '"\n#1 \"$name\"\n"' -- $SETUPS setup.ml.in setup.ml
13+
cp oasis/common.backup oasis/common
14+
cp oasis/benchmarks.backup oasis/benchmarks
15+
cp oasis/piqi.backup oasis/piqi
16+
sed -i 's/.*Build$.*//' _oasis
17+
sed -i 's/.*CCOpt:.*//' _oasis
18+
sed -i 's/.*CCLib:.*//' _oasis
19+
20+
# call setup twice so that it can capture the AB deps
21+
for pass in `seq 2`; do
22+
oasis setup
23+
ocamlfind ocamlopt unix.cmxa setup.ml -o setup.exe
24+
rm setup.cmx setup.cmi setup.o
25+
./setup.exe -configure --prefix $(opam config var prefix)
26+
done

lib/bap_disasm/OMakefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# You may modify this file freely. It is not overwritten by oasis
2+
# setup once it exists. See the OMakefile in the topmost directory
3+
# for more documentation.
4+
5+
CFLAGS += -O2
6+
CXXFLAGS += -std=c++11 -fPIC -Ilib/bap_disasm -O2
7+
LDFLAGS += -lstdc++
8+
OCAMLMKLIBFLAGS += -lstdc++
9+
10+
include _oasis_hier.om
11+
12+
# subdirectories
13+
.SUBDIRS: $(OASIS_SUBDIRS)
14+
15+
# local phonies
16+
.PHONY: build-here doc-here install-here uninstall-here reinstall-here pre-install-here clean-here distclean-here
17+
18+
include _oasis_build.om
19+
include _oasis_install.om
20+
21+
22+
DefineBuildRules()
23+
DefineInstallRules()
24+
25+
build-here: $(BUILD_TARGETS)
26+
doc-here: $(BUILD_DOC_TARGETS)
27+
install-here: $(INSTALL_TARGETS)
28+
uninstall-here: $(UNINSTALL_TARGETS)
29+
reinstall-here: $(REINSTALL_TARGETS)
30+
pre-install-here:
31+
32+
clean-here:
33+
rm -f $(OASIS_clean_list)
34+
rm -rf $(OASIS_rec_clean_list)
35+
section
36+
OASIS_rmdir($(OASIS_dir_clean_list))
37+
38+
distclean-here:
39+
rm -f $(OASIS_distclean_list)
40+
rm -rf $(OASIS_rec_distclean_list)
41+
section
42+
OASIS_rmdir($(OASIS_dir_distclean_list))
43+
44+
build: build-here
45+
doc: doc-here
46+
install: install-here
47+
uninstall: uninstall-here
48+
reinstall: reinstall-here
49+
clean: clean-here
50+
distclean: distclean-here

lib/bap_disasm/disasm.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <vector>
22
#include <memory>
33
#include <set>
4+
#include <cstdint>
45

56
extern "C" {
67
#include "disasm.h"

lib/bap_llvm/OMakefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# You may modify this file freely. It is not overwritten by oasis
2+
# setup once it exists. See the OMakefile in the topmost directory
3+
# for more documentation.
4+
5+
CFLAGS += -O2
6+
CXXFLAGS += -O2 -std=c++11 -fPIC -I$(ROOT)/lib/bap_disasm -I/usr/lib/llvm-6.0/include -std=c++0x -fuse-ld=gold -Wl,--no-keep-files-mapped -Wl,--no-map-whole-files -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -DNDEBUG -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
7+
8+
OCAMLMKLIBFLAGS += -L/usr/lib/llvm-6.0/lib -lLLVM-6.0 -dllpath /usr/lib/llvm-6.0/lib -lstdc++ -lz -lrt -ldl -ltinfo -lpthread -lm -lcurses
9+
10+
11+
include _oasis_hier.om
12+
13+
# subdirectories
14+
.SUBDIRS: $(OASIS_SUBDIRS)
15+
16+
# local phonies
17+
.PHONY: build-here doc-here install-here uninstall-here reinstall-here pre-install-here clean-here distclean-here
18+
19+
include _oasis_build.om
20+
include _oasis_install.om
21+
22+
DefineBuildRules()
23+
DefineInstallRules()
24+
25+
build-here: $(BUILD_TARGETS)
26+
doc-here: $(BUILD_DOC_TARGETS)
27+
install-here: $(INSTALL_TARGETS)
28+
uninstall-here: $(UNINSTALL_TARGETS)
29+
reinstall-here: $(REINSTALL_TARGETS)
30+
pre-install-here:
31+
32+
clean-here:
33+
rm -f $(OASIS_clean_list)
34+
rm -rf $(OASIS_rec_clean_list)
35+
section
36+
OASIS_rmdir($(OASIS_dir_clean_list))
37+
38+
distclean-here:
39+
rm -f $(OASIS_distclean_list)
40+
rm -rf $(OASIS_rec_distclean_list)
41+
section
42+
OASIS_rmdir($(OASIS_dir_distclean_list))
43+
44+
build: build-here
45+
doc: doc-here
46+
install: install-here
47+
uninstall: uninstall-here
48+
reinstall: reinstall-here
49+
clean: clean-here
50+
distclean: distclean-here

oasis/abi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ Library bap_abi
77
Path: lib/bap_abi
88
FindlibName: bap-abi
99
CompiledObject: best
10-
BuildDepends: bap
10+
BuildDepends: bap, core_kernel, ppx_jane
1111
Modules: Bap_abi
1212

1313
Library abi_plugin
1414
Build$: flag(everything) || flag(abi)
1515
Path: plugins/abi
1616
FindlibName: bap-plugin-abi
1717
CompiledObject: best
18-
BuildDepends: bap, bap-abi
18+
BuildDepends: bap, bap-abi, core_kernel
1919
InternalModules: Abi_main
2020
XMETADescription: apply abi information to a project
2121
XMETAExtraLines: tags="abi, pass"

oasis/api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Library bap_api
77
Path: lib/bap_api
88
FindlibName: bap-api
99
CompiledObject: best
10-
BuildDepends: bap
10+
BuildDepends: bap, core_kernel, ppx_jane
1111
Modules: Bap_api
1212

1313

@@ -16,7 +16,7 @@ Library api_plugin
1616
Path: plugins/api
1717
FindlibName: bap-plugin-api
1818
CompiledObject: best
19-
BuildDepends: bap, bap-api, fileutils
19+
BuildDepends: bap, bap-api, fileutils, core_kernel, ppx_jane, regular
2020
InternalModules: Api_main, Api_config
2121
XMETADescription: add parameters to subroutines based on known API
2222
DataFiles: api/c/*.h ($datadir/bap-api/c)

oasis/arm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Library "bap-arm"
77
Path: lib/arm
88
Build$: flag(everything) || flag(arm)
99
BuildDepends: bap
10+
BuildDepends: bap, core_kernel, ppx_jane, regular
1011
FindlibName: bap-arm
1112
Modules:
1213
ARM,
@@ -33,7 +34,7 @@ Library arm_plugin
3334
Build$: flag(everything) || flag(arm)
3435
Path: plugins/arm
3536
FindlibName: bap-plugin-arm
36-
BuildDepends: bap-abi, bap-arm, bap-c
37+
BuildDepends: bap, bap-abi, bap-arm, bap-c, core_kernel, bap-future, bap-api, regular
3738
InternalModules: Arm_main, Arm_gnueabi
3839
XMETADescription: provide ARM lifter
3940
XMETAExtraLines: tags="arm, lifter"

0 commit comments

Comments
 (0)