Skip to content
Closed
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
45 changes: 43 additions & 2 deletions .github/workflows/build-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ jobs:
set -x
./configure --disable-warn-error --disable-ocamldoc \
--disable-ocamltest --disable-stdlib-manpages \
--prefix="$PREFIX" || failed=$?
--prefix="$PREFIX" --with-additional-stublibsdir \
--with-relative-libdir --enable-runtime-search \
--enable-runtime-search-target=fallback || failed=$?
if ((failed)) ; then set +x
echo ; echo "::group::config.log content ($(wc -l config.log) lines)"
cat config.log ; echo '::endgroup::' ; exit $failed
Expand Down Expand Up @@ -91,6 +93,8 @@ jobs:
run: |
set -x
./configure --prefix="$HOME/cross" --target=x86_64-w64-mingw32 \
--with-additional-stublibsdir --with-relative-libdir \
--enable-runtime-search --enable-runtime-search-target=fallback \
TARGET_LIBDIR="$TESTDIR" || failed=$?
if ((failed)) ; then set +x
echo ; echo "::group::config.log content ($(wc -l config.log) lines)"
Expand Down Expand Up @@ -118,6 +122,21 @@ jobs:
name: x86_64-w64-mingw32-executable
path: example.exe
retention-days: 1
- name: Move the cross compiler
run: |
mv $HOME/cross $HOME/relocated
ln -srf "$HOME/relocated/bin/flexlink.opt.exe" "$HOME/.local/bin/flexlink"
- name: Show opt.opt configuration after relocation
run: |
set -x
$HOME/relocated/bin/ocamlopt.opt.exe -config
cat runtime/build_config.h
- name: Cross compile a small program after relocation
run: |
printf %s "$EXAMPLE_PROGRAM$COMPLIBS_PROG_X86_64" > example.ml
set -x
cat example.ml
$HOME/relocated/bin/ocamlopt.opt.exe -I $HOME/relocated/lib/ocaml/compiler-libs/ ocamlcommon.cmxa ocamloptcomp.cmxa example.ml -o example.exe -verbose
- name: Test cross sak
run: |
printf %s "$STR_UTF16" > utf16.ref
Expand Down Expand Up @@ -161,10 +180,12 @@ jobs:
with:
submodules: true
persist-credentials: false
- name: Configure, build and install Linux-to-Windows OCaml
- name: Configure, build and install Linux-to-ARM-Linux OCaml
run: |
set -x
./configure --prefix="$HOME/cross" --target=aarch64-linux-gnu \
--with-additional-stublibsdir --with-relative-libdir \
--enable-runtime-search --enable-runtime-search-target=fallback \
|| failed=$?
if ((failed)) ; then set +x
echo ; echo "::group::config.log content ($(wc -l config.log) lines)"
Expand All @@ -187,6 +208,24 @@ jobs:
run: |
set -x
qemu-aarch64 -L /usr/aarch64-linux-gnu example
- name: Move the cross compiler
run: |
mv $HOME/cross $HOME/relocated
- name: Show opt.opt configuration
run: |
set -x
$HOME/relocated/bin/ocamlopt.opt -config
cat runtime/build_config.h
- name: Cross compile a small program
run: |
printf %s "$EXAMPLE_PROGRAM$COMPLIBS_PROG_AARCH64" > example.ml
set -x
cat example.ml
$HOME/relocated/bin/ocamlopt.opt -I $HOME/relocated/lib/ocaml/compiler-libs/ ocamlcommon.cmxa ocamloptcomp.cmxa example.ml -o example -verbose
- name: Run the small example program
run: |
set -x
qemu-aarch64 -L /usr/aarch64-linux-gnu example
- name: Test cross sak
run: |
printf %s "$STR_UTF16" > utf16.ref
Expand Down Expand Up @@ -253,6 +292,8 @@ jobs:
# program should _not_ be run with cleanup on exit (so no
# `c=1` in `OCAMLRUNPARAM`)
./configure --prefix="$HOME/cross" --target=$TARGET \
--with-additional-stublibsdir --with-relative-libdir \
--enable-runtime-search --enable-runtime-search-target=fallback \
TARGET_LIBDIR="/dummy/directory" \
CC="$DIR/clang --target=$TARGET" \
AR="$DIR/llvm-ar" \
Expand Down
5 changes: 5 additions & 0 deletions Makefile.build_config.in
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ DOCDIR=@docdir@
TARGET_LIBDIR=@TARGET_LIBDIR@
TARGET_LIBDIR_IS_RELATIVE=@target_libdir_is_relative@

### Where to look for the standard library on host
# The difference with LIBDIR (in Makefile.config) is that this is just the
# relative path when --with-relative-libdir is enabled
HOST_LIBDIR=@host_libdir@

unix_directory = @unix_directory@
unix_library = @unix_library@

Expand Down
4 changes: 0 additions & 4 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,6 @@ ifeq "$(TARGET_LIBDIR_IS_RELATIVE)" "true"
$(if $(SRCDIR_REAL_ENCODED),:.=$(SRCDIR_REAL_ENCODED))
endif # ifeq "$(TARGET_LIBDIR_IS_RELATIVE)" "true"

# Allow Makefile.cross to override the Standard Library default for the compiler
# itself.
HOST_LIBDIR ?= $(TARGET_LIBDIR)

OC_COMMON_LINKFLAGS += \
-set-runtime-default \
$(call QUOTE_SINGLE,standard_library_default=$(HOST_LIBDIR))
Expand Down
3 changes: 1 addition & 2 deletions Makefile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ CROSS_OVERRIDES=OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \
# be overridden with -set-runtime-default so that cross/bin/ocamlopt instead has
# cross/lib/ocaml for Config.standard_library_default
CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \
BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex \
HOST_LIBDIR="$(LIBDIR)"
BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex
CROSS_COMPILERLIBS_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc \
CAMLOPT="$(ROOTDIR)/ocamlopt.opt$(EXE) $(STDLIBFLAGS)"

Expand Down
44 changes: 36 additions & 8 deletions configure

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

38 changes: 27 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ AC_SUBST([compute_deps])
AC_SUBST([ocaml_prefix])
AC_SUBST([ocaml_bindir])
AC_SUBST([ocaml_libdir])
AC_SUBST([host_libdir])
AC_SUBST([TARGET_LIBDIR])
AC_SUBST([QS])
AC_SUBST([ar_supports_response_files])
Expand Down Expand Up @@ -478,11 +479,16 @@ AS_IF([test -n "$csc"],
dnl The separator should be being treated differently for host/target for
dnl cross-compilers, but the installation layout for cross-compilers is already
dnl incorrect (for example, ld.conf is processed by _both_ the host and target
dnl runtimes), so this is left as target-specific for now.
dnl runtimes), so this is left as host-specific for now as being more useful
dnl (ie things break at compile-time if paths are incorrect on the host)
AS_CASE([$host],
[*-w64-mingw32*|*-pc-windows],
[host_dir_sep='\'],
[host_dir_sep='/'])
AS_CASE([$target],
[*-w64-mingw32*|*-pc-windows],
[default_separator='\'],
[default_separator='/'])
[target_dir_sep='\'],
[target_dir_sep='/'])

# Environment variables that are taken into account

Expand Down Expand Up @@ -683,7 +689,7 @@ AC_ARG_WITH([additional-stublibsdir],
[no],
[ocaml_additional_stublibs_dir=''],
[yes],
[ocaml_additional_stublibs_dir="..${default_separator}stublibs"],
[ocaml_additional_stublibs_dir="..${host_dir_sep}stublibs"],
[ocaml_additional_stublibs_dir="$withval"])],
[ocaml_additional_stublibs_dir=''])

Expand Down Expand Up @@ -740,7 +746,7 @@ AC_ARG_WITH([relative-libdir],
[no],
[bindir_to_libdir=''],
[yes],
[bindir_to_libdir="..${default_separator}lib${default_separator}ocaml"],
[bindir_to_libdir="..${host_dir_sep}lib${host_dir_sep}ocaml"],
[bindir_to_libdir="$withval"])],
[bindir_to_libdir=''])

Expand Down Expand Up @@ -3121,7 +3127,8 @@ AS_CASE([$cygwin_build_env,$host],
AS_IF([test x"$libdir_given" = 'xno'],
[AS_IF([test x"$bindir_to_libdir" != 'x'],
[ocaml_libdir="$bindir_to_libdir"
target_libdir_is_relative=true
AS_IF([test x"$TARGET_LIBDIR" = x],
[target_libdir_is_relative=true])
AS_CASE([$cygwin_build_env,$host],
[true,*-w64-mingw32*|true,*-pc-windows],
[build_bindir_to_libdir="$(LC_ALL=C.UTF-8 cygpath \
Expand All @@ -3136,9 +3143,18 @@ AS_IF([test x"$libdir_given" = 'xno'],
[AC_MSG_ERROR(m4_normalize([--with-relative-libdir and --libdir cannot both
be specified]))])])

AS_IF([test x"$bindir_to_libdir" != 'x' && test x"$TARGET_LIBDIR" != 'x'],
[AC_MSG_ERROR(m4_normalize([--with-relative-libdir and TARGET_LIBDIR cannot
both be specified]))])
AS_CASE([$TARGET_LIBDIR],
[.|..|.${target_dir_sep}*|..${target_dir_sep}*],
[target_libdir_is_relative=true])

host_libdir='${TARGET_LIBDIR}'

AS_IF([$cross_compiler],
[AS_IF([test x"$bindir_to_libdir" != 'x'],
[host_libdir="$bindir_to_libdir"])],
[AS_IF([test x"$bindir_to_libdir" != 'x' && test x"$TARGET_LIBDIR" != 'x'],
[AC_MSG_ERROR(m4_normalize([--with-relative-libdir and TARGET_LIBDIR cannot
both be specified]))])])

# Define a few macros that were defined in config/m-nt.h
# but whose value is not guessed properly by configure
Expand Down Expand Up @@ -3271,13 +3287,13 @@ AC_CONFIG_COMMANDS([runtime/ld.conf],
test x"$ocaml_additional_stublibs_dir" = 'x' || \
echo "$ocaml_additional_stublibs_dir" > runtime/ld.conf
if $supports_shared_libraries; then
echo ".${default_separator}stublibs" >> runtime/ld.conf
echo ".${host_dir_sep}stublibs" >> runtime/ld.conf
fi
echo "." >> runtime/ld.conf],
[ocaml_additional_stublibs_dir=\
'$(echo "$ocaml_additional_stublibs_dir" | sed -e "s/'/'\"'\"'/g")'
ocaml_libdir='$(echo "$ocaml_libdir" | sed -e "s/'/'\"'\"'/g")'
default_separator='$default_separator'
host_dir_sep='$host_dir_sep'
supports_shared_libraries='$supports_shared_libraries'])

# Just before config.status is generated, determine the final values for MKEXE,
Expand Down
Loading