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

Add support for freestanding targets #22

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion asmcomp/amd64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ let end_assembly() =
D.size frametable (ConstSub (ConstThis, ConstLabel frametable))
end;

if system = S_linux || system = S_freebsd then
if system = S_linux || system = S_freebsd || system = S_none then
(* Mark stack as non-executable, PR#4564 *)
D.section [".note.GNU-stack"] (Some "") [ "%progbits" ];

Expand Down
2 changes: 1 addition & 1 deletion asmcomp/arm64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ let end_assembly () =
emit_symbol_type emit_symbol lbl "object";
emit_symbol_size lbl;
begin match Config.system with
| "linux" ->
| "linux" | "none" (* freestanding *) ->
(* Mark stack as non-executable *)
` .section .note.GNU-stack,\"\",%progbits\n`
| _ -> ()
Expand Down
2 changes: 2 additions & 0 deletions asmcomp/x86_proc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type system =
| S_freebsd
| S_netbsd
| S_openbsd
| S_none (* freestanding *)

| S_unknown

Expand All @@ -43,6 +44,7 @@ let system = match Config.system with
| "freebsd" -> S_freebsd
| "netbsd" -> S_netbsd
| "openbsd" -> S_openbsd
| "none" -> S_none

| _ -> S_unknown

Expand Down
1 change: 1 addition & 0 deletions asmcomp/x86_proc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type system =
| S_freebsd
| S_netbsd
| S_openbsd
| S_none (* freestanding *)

| S_unknown

Expand Down
36 changes: 35 additions & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,24 @@ AC_CONFIG_COMMANDS_PRE(OCAML_QUOTED_STRING_ID)

AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# Allow "ocaml" as target OS for freestanding compiler by temporarily rewriting
# the target OS to "none" to generate the canonical target
real_target_alias="$target_alias"
AS_CASE([$target_alias],
[*-*-*-ocaml],
[ac_save_IFS=$IFS
IFS='-'
set x $target_alias
target_alias="$2-$3-none"
IFS=$ac_save_IFS],
[*-*-ocaml],
[ac_save_IFS=$IFS
IFS='-'
set x $target_alias
target_alias="$2-none"
IFS=$ac_save_IFS])
AC_CANONICAL_TARGET
target_alias="$real_target_alias"

# Override cross_compiling and ac_tool_prefix variables since the C toolchain is
# used to generate target code when building a cross compiler
Expand Down Expand Up @@ -1175,7 +1192,9 @@ AS_CASE([$ocaml_cc_vendor,$target],
[oc_ldflags='-brtl -bexpfull'
AC_DEFINE([HAS_ARCH_CODE32], [1])],
[gcc-*,powerpc-*-linux*],
[oc_ldflags="-mbss-plt"])
[oc_ldflags="-mbss-plt"],
[*,*-*-none|*,*-*-elf*],
[ostype="None"])

# Winpthreads emulation library for the MSVC port
AC_MSG_CHECKING([for winpthreads sources])
Expand Down Expand Up @@ -1584,7 +1603,19 @@ AS_CASE([$target],
[riscv64-*-linux*],
[has_native_backend=yes; arch=riscv; model=riscv64; system=linux],
[x86_64-*-gnu*],
[has_native_backend=yes; arch=amd64; system=gnu]
[has_native_backend=yes; arch=amd64; system=gnu],
[aarch64-*-none|arm64-*-none|aarch64-*-elf*|arm64-*-elf*],
[has_native_backend=yes; arch=arm64; system=none],
[powerpc64le*-*-none|powerpc64le*-*-elf*],
[has_native_backend=yes; arch=power; model=ppc64le; system=none],
[powerpc64*-*-none|powerpc64*-*-elf*],
[has_native_backend=yes; arch=power; model=ppc64; system=none],
[riscv64-*-none|riscv64-*-elf*],
[has_native_backend=yes; arch=riscv; model=riscv64; system=none],
[s390x*-*-none|s390x*-*-elf*],
[has_native_backend=yes; arch=s390x; model=z10; system=none],
[x86_64-*-none|x86_64-*-elf*],
[has_native_backend=yes; arch=amd64; system=none]
)

AS_CASE([$arch],
Expand Down
2 changes: 1 addition & 1 deletion runtime/amd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ G(caml_negf_mask):
G(caml_absf_mask):
.quad 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF

#if defined(SYS_linux) || defined(SYS_freebsd)
#if defined(SYS_linux) || defined(SYS_freebsd) || defined(SYS_none)
/* Mark stack as non-executable, PR#4564 */
.section .note.GNU-stack,"",%progbits
#endif
Loading