Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow linking C++ #48

Merged
merged 3 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Next version
- GPR#49: Adding support for 64bit GNAT compiler (Johannes Kanig)
- GPR#64: Fix problem with setting page permission during relocation (report
by Dmitry Bely)
- GPR#48: Enable linking of C++ object files for mingw ports (David Allsopp)

Version 0.37
- Bug fix: the IMAGE_SCN_LNK_NRELOC_OVFL section flag was not propertly reset when
Expand Down
10 changes: 8 additions & 2 deletions reloc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ let needed imported defined unalias obj =
| Some s when not (StrSet.mem name defined) ->
imported := StrSet.add s !imported;
if StrSet.mem s defined then s else name
| None when not (StrSet.mem name defined) && StrSet.mem ("__imp_" ^ name) defined ->
imported := StrSet.add ("__imp_" ^ name) !imported;
"__imp_" ^ name
| _ -> name
in
List.fold_left
Expand Down Expand Up @@ -662,7 +665,10 @@ let build_dll link_exe output_file files exts extra_args =
let loaded_filenames : (string,unit) Hashtbl.t = Hashtbl.create 16 in
let read_file fn =
if Lib.is_dll fn then `Lib ([], dll_exports fn)
else Lib.read fn
else begin
if !verbose >= 2 then Printf.printf "** open: %s\n" fn;
Lib.read fn
end
in
let files = List.map (fun fn -> fn, read_file fn) files in

Expand Down Expand Up @@ -1244,7 +1250,7 @@ let setup_toolchain () =
List.iter (Printf.printf " %s\n%!") lib_search_dirs;
end;
default_libs :=
["-lmingw32"; "-lgcc"; "-lmoldname"; "-lmingwex"; "-lmsvcrt";
["-lmingw32"; "-lgcc"; "-lgcc_eh"; "-lmoldname"; "-lmingwex"; "-lmsvcrt";
"-luser32"; "-lkernel32"; "-ladvapi32"; "-lshell32" ];
if !exe_mode = `EXE then default_libs := "crt2.o" :: !default_libs
else default_libs := "dllcrt2.o" :: !default_libs
Expand Down