Skip to content

Commit

Permalink
Use a Makefile to build libmirage-solo5_bindings.a
Browse files Browse the repository at this point in the history
The dune C compilation support adds CFLAGS (specifically -fPIC and
-fno-strict-aliasing) which are not necessary and should be avoided when
compiling libmirage-solo5_bindings.a. This follows from the discussion and
solution in mirage/mirage-xen#23.

Co-authored-by: Martin Lucina <[email protected]>
  • Loading branch information
hannesm and mato committed Oct 26, 2020
1 parent e1d1e80 commit b871937
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(lang dune 2.0)
(lang dune 2.6)
(name mirage-solo5)
17 changes: 17 additions & 0 deletions lib/bindings/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig

CC ?= cc
FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags ocaml-freestanding)
CFLAGS := $(FREESTANDING_CFLAGS) \
-O2 -std=c99 -Wall -Werror

.PHONY: all clean
all: libmirage-solo5_bindings.a

OBJS=alloc_pages_stubs.o clock_stubs.o mm_stubs.o atomic_stubs.o cstruct_stubs.o solo5_block_stubs.o barrier_stubs.o main.o solo5_console_stubs.o checksum_stubs.o solo5_net_stubs.o

libmirage-solo5_bindings.a: $(OBJS)
$(AR) r $@ $^

clean:
$(RM) $(OBJS) libmirage-xen_bindings.a
4 changes: 0 additions & 4 deletions lib/cflags.sh

This file was deleted.

23 changes: 11 additions & 12 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
(name oS)
(public_name mirage-solo5)
(private_modules lifecycle main mM time solo5)
(libraries mirage-runtime bheap lwt cstruct metrics duration)
(foreign_archives mirage-solo5_bindings))
(libraries mirage-runtime bheap lwt cstruct metrics duration))

(foreign_library
(archive_name mirage-solo5_bindings)
(language c)
(names alloc_pages_stubs clock_stubs mm_stubs atomic_stubs cstruct_stubs
solo5_block_stubs barrier_stubs main solo5_console_stubs checksum_stubs
solo5_net_stubs)
(flags (:include cflags.sexp) -O2 -std=c99 -Wall -Werror))
(rule
(deps (source_tree bindings))
(target libmirage-solo5_bindings.a)
(action
(no-infer
(progn
(chdir bindings (run %{make}))
(copy bindings/libmirage-solo5_bindings.a libmirage-solo5_bindings.a)))))

(include_subdirs unqualified)

(rule (with-stdout-to cflags.sexp (run ./cflags.sh)))

(install
(section lib)
(files (bindings/mirage-solo5.pc as ../pkgconfig/mirage-solo5.pc)))
(files (bindings/mirage-solo5.pc as ../pkgconfig/mirage-solo5.pc)
libmirage-solo5_bindings.a))
2 changes: 1 addition & 1 deletion mirage-solo5.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build: [
["dune" "build" "-p" name "-j" jobs ]
]
depends: [
"dune" {>= "2.0.0"}
"dune" {>= "2.6.0"}
"bheap" {>= "2.0.0"}
"ocaml" {>= "4.06.0"}
"cstruct" {>= "1.0.1"}
Expand Down

0 comments on commit b871937

Please sign in to comment.