Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/59'
Browse files Browse the repository at this point in the history
  • Loading branch information
mmottl committed Aug 1, 2024
2 parents b37da7c + d18bcbf commit c17409f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## 5.1.0 (2021-09-22)
### Pending

- Don't use `-lpthread` and non-MSVC flags with MSVC compiler

### 5.1.0 (2021-09-22)

- Added let&-operator for implicit closing of an opened database.

Expand Down
17 changes: 16 additions & 1 deletion src/config/discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ let split_ws str =
done;
List.rev !lst

let add_compiler_args ~is_msvc ~cflags ~libs =
let module C = Configurator.V1 in
match is_msvc with
| true -> { C.Pkg_config.cflags = cflags @ [ "/O2" ]; libs }
| false ->
{
C.Pkg_config.cflags = cflags @ [ "-O2"; "-fPIC"; "-DPIC" ];
libs = libs @ [ "-lpthread" ];
}

let () =
let module C = Configurator.V1 in
C.main ~name:"sqlite3" (fun c ->
Expand All @@ -76,6 +86,11 @@ let () =
| "macosx" -> true
| _ -> false)
in
let is_msvc =
opt_map (C.ocaml_config_var c "ccomp_type") ~default:false ~f:(function
| "msvc" -> true
| _ -> false)
in
let is_mingw =
opt_map (C.ocaml_config_var c "system") ~default:false ~f:(function
| "mingw" | "mingw64" -> true
Expand Down Expand Up @@ -111,6 +126,6 @@ let () =
| [ libs ] -> split_ws libs
| _ -> failwith "pkg-config failed to return libs"
in
let conf = { C.Pkg_config.cflags; libs } in
let conf = add_compiler_args ~is_msvc ~cflags ~libs in
C.Flags.write_sexp "c_flags.sexp" conf.cflags;
C.Flags.write_sexp "c_library_flags.sexp" conf.libs)
5 changes: 1 addition & 4 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
(names sqlite3_stubs)
(flags
(:standard)
(:include c_flags.sexp)
-O2
-fPIC
-DPIC))
(:include c_flags.sexp)))
(c_library_flags
(:include c_library_flags.sexp)))

Expand Down

0 comments on commit c17409f

Please sign in to comment.