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

[Relocatable] 3: Test compiler installations #158

Open
wants to merge 8 commits into
base: relocatable-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
19 changes: 19 additions & 0 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -10578,6 +10578,25 @@ testsuite/tools/parsecmmaux.cmi : \
parsing/location.cmi \
lambda/debuginfo.cmi \
middle_end/backend_var.cmi
testsuite/tools/test_in_prefix.cmo : \
otherlibs/unix/unix.cmi \
utils/misc.cmi \
utils/config.cmi \
driver/compmisc.cmi \
file_formats/cmx_format.cmi \
utils/ccomp.cmi \
bytecomp/bytesections.cmi \
testsuite/tools/test_in_prefix.cmi
testsuite/tools/test_in_prefix.cmx : \
otherlibs/unix/unix.cmx \
utils/misc.cmx \
utils/config.cmx \
driver/compmisc.cmx \
file_formats/cmx_format.cmi \
utils/ccomp.cmx \
bytecomp/bytesections.cmx \
testsuite/tools/test_in_prefix.cmi
testsuite/tools/test_in_prefix.cmi :
otherlibs/dynlink/byte/dynlink.cmo : \
otherlibs/dynlink/dynlink_types.cmi \
otherlibs/dynlink/byte/dynlink_symtable.cmi \
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/build-msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,19 @@ jobs:
env:
HOST: ${{ matrix.x86_64 && 'x86_64-pc-windows' || 'i686-pc-windows' }}
CC: ${{ matrix.cc }}
CONFIGURE_FLAGS: >-
--cache-file=config.cache
--prefix "$PWD/install"
--host=$HOST
CC=$CC
--enable-ocamltest
${{ matrix.x86_64 && '--enable-native-toplevel' || '--disable-native-toplevel' }}
run: >-
eval $(tools/msvs-promote-path) ;
if ! ./configure --cache-file=config.cache --host=$HOST CC=$CC ; then
if ! ./configure ${{ env.CONFIGURE_FLAGS }} ; then
rm -rf config.cache ;
failed=0 ;
./configure --cache-file=config.cache --host=$HOST CC=$CC \
./configure ${{ env.CONFIGURE_FLAGS }} \
|| failed=$?;
if ((failed)) ; then cat config.log ; exit $failed ; fi ;
fi ;
Expand Down Expand Up @@ -137,3 +144,14 @@ jobs:
run: >-
eval $(tools/msvs-promote-path) ;
make -j tests ;

- name: Install
shell: bash
run: >-
make install

- name: Test in prefix
shell: bash
run: >-
eval $(tools/msvs-promote-path) ;
make -f Makefile.test -C testsuite/in_prefix test-in-prefix
27 changes: 24 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ jobs:
if: matrix.id == 'normal'
run: |
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh install
- name: Test in prefix
if: matrix.id == 'normal'
run: |
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test-in-prefix
- name: Build the manual
if: matrix.id == 'normal' && needs.build.outputs.manual_changed == 'true'
run: |
Expand All @@ -157,14 +161,17 @@ jobs:
config_arg: CFLAGS='-O0'
- name: macos-x86_64
os: macos-13
in-prefix-test: true
- name: macos-arm64
os: macos-14
in-prefix-test: true
- name: static
os: ubuntu-latest
config_arg: --disable-shared
config_arg: --disable-shared --disable-native-toplevel
in-prefix-test: true
- name: minimal
os: ubuntu-latest
config_arg: --disable-native-compiler --disable-shared --disable-debug-runtime --disable-instrumented-runtime --disable-systhreads --disable-str-lib --disable-unix-lib --disable-ocamldoc
config_arg: --disable-native-compiler --disable-native-toplevel --disable-shared --disable-debug-runtime --disable-instrumented-runtime --disable-systhreads --disable-str-lib --disable-unix-lib --disable-ocamldoc
fail-fast: false
steps:
- name: Checkout
Expand Down Expand Up @@ -215,6 +222,14 @@ jobs:
for dir in $PARALLEL_TESTS; do \
bash -cxe "SHOW_TIMINGS=1 tools/ci/actions/runner.sh test_prefix $dir"; \
done
- name: Install
if: ${{ matrix.in-prefix-test }}
run: |
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh install
- name: Test in prefix
if: ${{ matrix.in-prefix-test }}
run: |
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test-in-prefix

i386:
runs-on: ubuntu-latest
Expand All @@ -233,10 +248,16 @@ jobs:
- name: configure tree
run: |
chown -R ocaml:ocaml .
MAKE_ARG=-j su ocaml -c "bash -xe tools/ci/actions/runner.sh configure"
MAKE_ARG=-j CONFIG_ARG=--disable-native-toplevel su ocaml -c "bash -xe tools/ci/actions/runner.sh configure"
- name: Build
run: |
MAKE_ARG=-j su ocaml -c "bash -xe tools/ci/actions/runner.sh build"
- name: Run the testsuite
run: |
su ocaml -c "bash -xe tools/ci/actions/runner.sh test"
- name: Install
run: |
su ocaml -c "bash -xe tools/ci/actions/runner.sh install"
- name: Test in prefix
run: |
su ocaml -c "bash -xe tools/ci/actions/runner.sh test-in-prefix"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ META
/testsuite/tools/parsecmm.ml
/testsuite/tools/parsecmm.mli
/testsuite/tools/parsecmm.output
/testsuite/tools/test_in_prefix
/testsuite/tools/test_in_prefix.opt

/tools/ocamldep
/tools/ocamldep.opt
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,19 @@ $(asmgen_OBJECT): $(asmgen_SOURCE)
$(V_ASM)$(ASPP) $(OC_ASPPFLAGS) -o $@ $< || $(ASPP_ERROR)
endif

test_in_prefix_SOURCES = \
$(addprefix testsuite/tools/,test_in_prefix.mli test_in_prefix.ml)
test_in_prefix_LIBRARIES = otherlibs/unix/unix compilerlibs/ocamlcommon

testsuite/tools/test_in_prefi%: CAMLC = $(BEST_OCAMLC) $(STDLIBFLAGS)

testsuite/tools/test_in_prefix$(EXE): OC_BYTECODE_LINKFLAGS += -custom

testsuite/tools/test_in_prefi%: CAMLOPT = $(BEST_OCAMLOPT) $(STDLIBFLAGS)

testsuite/tools/test_in_prefix.%: \
OC_COMMON_COMPFLAGS += -rectypes

ocamltest/ocamltest$(EXE): OC_BYTECODE_LINKFLAGS += -custom -g

ocamltest/ocamltest$(EXE): ocamlc ocamlyacc ocamllex
Expand Down Expand Up @@ -2039,6 +2052,9 @@ partialclean::
rm -f $(addprefix testsuite/tools/*.,cm* o obj a lib)
rm -f testsuite/tools/codegen testsuite/tools/codegen.exe
rm -f testsuite/tools/expect testsuite/tools/expect.exe
rm -f testsuite/tools/test_in_prefix testsuite/tools/test_in_prefix.exe
rm -f testsuite/tools/test_in_prefix.opt \
testsuite/tools/test_in_prefix.opt.exe
rm -f testsuite/tools/lexcmm.ml
rm -f $(addprefix testsuite/tools/parsecmm., ml mli output)

Expand Down
26 changes: 17 additions & 9 deletions configure

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

21 changes: 13 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1400,14 +1400,6 @@ AS_IF([test x"$supports_shared_libraries" = 'xtrue'],
[aarch64-*-netbsd*], [natdynlink=true],
[riscv*-*-linux*], [natdynlink=true])])

AS_CASE([$enable_native_toplevel,$natdynlink],
[yes,false],
[AC_MSG_ERROR(m4_normalize([
The native toplevel requires native dynlink support]))],
[yes,*],
[install_ocamlnat=true],
[install_ocamlnat=false])

# Try to work around the Skylake/Kaby Lake processor bug.
AS_CASE(["$ocaml_cc_vendor,$host"],
[*gcc*,x86_64-*|*gcc*,i686-*],
Expand Down Expand Up @@ -1567,6 +1559,14 @@ AS_IF([$natdynlink],
[natdynlink_archive="dynlink.cmxa"],
[natdynlink_archive=""])

AS_CASE([$enable_native_toplevel,$natdynlink],
[yes,false],
[AC_MSG_ERROR(m4_normalize([
The native toplevel requires native dynlink support]))],
[yes,*],
[install_ocamlnat=true],
[install_ocamlnat=false])

AC_DEFINE_UNQUOTED([OCAML_OS_TYPE], ["$ostype"])

AC_CHECK_TOOL([DIRECT_LD],[ld])
Expand Down Expand Up @@ -2500,6 +2500,11 @@ AS_CASE([$enable_ocamltest,OCAML__DEVELOPMENT_VERSION],
ocamltest_target=ocamltest
ocamltest_opt_target=ocamltest.opt
ocamltest='ocamltest'
AS_IF([$native_compiler],
[optional_native_tools="$optional_native_tools \
testsuite/tools/test_in_prefix.opt"],
[optional_bytecode_tools="$optional_bytecode_tools \
testsuite/tools/test_in_prefix"])
testsuite_tools='testsuite/tools/codegen testsuite/tools/expect'
optional_bytecode_tools="$optional_bytecode_tools $testsuite_tools"],
[build_ocamltest=false
Expand Down
15 changes: 11 additions & 4 deletions driver/compmisc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ let auto_include find_in_dir fn =
then the directories specified with the -H option (in command line order).
*)

let init_path ?(auto_include=auto_include) ?(dir="") () =
let reinit_path ?(auto_include=auto_include)
?(standard_library=Config.standard_library)
?(dir="") () =
let visible =
if !Clflags.use_threads then "+threads" :: !Clflags.include_dirs
else
Expand All @@ -44,19 +46,24 @@ let init_path ?(auto_include=auto_include) ?(dir="") () =
!Compenv.first_include_dirs]
in
let visible =
List.map (Misc.expand_directory Config.standard_library) visible
List.map (Misc.expand_directory standard_library) visible
in
let visible =
let std_include =
if !Clflags.no_std_include then [] else [standard_library]
in
(if !Clflags.no_cwd then [] else [dir])
@ List.rev_append visible (Clflags.std_include_dir ())
@ List.rev_append visible std_include
in
let hidden =
List.rev_map (Misc.expand_directory Config.standard_library)
List.rev_map (Misc.expand_directory standard_library)
!Clflags.hidden_include_dirs
in
Load_path.init ~auto_include ~visible ~hidden;
Env.reset_cache ()

let init_path = reinit_path ?standard_library:None

(* Return the initial environment in which compilation proceeds. *)

(* Note: do not do init_path() in initial_env, this breaks
Expand Down
2 changes: 2 additions & 0 deletions driver/compmisc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

val init_path :
?auto_include:Load_path.auto_include_callback -> ?dir:string -> unit -> unit
val reinit_path : ?auto_include:Load_path.auto_include_callback
-> ?standard_library:string -> ?dir:string -> unit -> unit
val initial_env : unit -> Env.t

(* Support for flags that can also be set from an environment variable *)
Expand Down
35 changes: 23 additions & 12 deletions otherlibs/systhreads/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ LIBNAME=threads
# That's why this dependency is handled in the Makefile directly
# and removed from the output of the C compiler during make depend

BYTECODE_C_OBJS=st_stubs.b.$(O)
NATIVECODE_C_OBJS=st_stubs.n.$(O)

THREADS_SOURCES = thread.ml event.ml

THREADS_BCOBJS = $(THREADS_SOURCES:.ml=.cmo)
Expand All @@ -55,15 +52,20 @@ all: lib$(LIBNAME).$(A) $(LIBNAME).cma $(CMIFILES)

allopt: lib$(LIBNAME)nat.$(A) $(LIBNAME).cmxa $(CMIFILES)

ifeq "$(NATDYNLINK)" "true"
allopt: $(LIBNAME).cmxs
endif

lib$(LIBNAME).$(A): OC_CFLAGS = $(OC_BYTECODE_CFLAGS)

lib$(LIBNAME).$(A): $(BYTECODE_C_OBJS)
$(V_OCAMLMKLIB)$(MKLIB) -o $(LIBNAME) $(BYTECODE_C_OBJS)
lib$(LIBNAME).$(A): st_stubs.b.$(O) st_stubs_shared.b.$(O)
@$(MKLIB) -o $(LIBNAME) st_stubs_shared.b.$(O)
$(V_OCAMLMKLIB)$(MKLIB) -custom -o $(LIBNAME) $<

lib$(LIBNAME)nat.$(A): OC_CFLAGS = $(OC_NATIVE_CFLAGS)

lib$(LIBNAME)nat.$(A): $(NATIVECODE_C_OBJS)
$(V_OCAMLMKLIB)$(MKLIB) -o $(LIBNAME)nat $^
lib$(LIBNAME)nat.$(A): st_stubs.n.$(O)
$(V_OCAMLMKLIB)$(MKLIB) -custom -o $(LIBNAME)nat $^

$(LIBNAME).cma: $(THREADS_BCOBJS)
$(V_OCAMLMKLIB)$(MKLIB) -o $(LIBNAME) -ocamlc '$(CAMLC)' -linkall $^
Expand All @@ -72,14 +74,20 @@ $(LIBNAME).cma: $(THREADS_BCOBJS)
$(LIBNAME).cmxa: $(THREADS_NCOBJS)
$(V_LINKOPT)$(CAMLOPT) -linkall -a -cclib -lthreadsnat -o $@ $^

# The following lines produce two object files st_stubs.b.$(O) and
# st_stubs.n.$(O) from the same source file st_stubs.c (it is compiled
# twice, each time with different options).
st_stubs_shared.n.$(O): OC_CFLAGS = $(OC_NATIVE_CFLAGS)

$(LIBNAME).cmxs: $(THREADS_NCOBJS) st_stubs_shared.n.$(O)
$(V_LINKOPT)$(CAMLOPT) -linkall -shared -o $@ $^

# The following lines produce object files based on st_stubs.c. Four objects are
# produced - a static and shared version in both bytecode and native versions.

st_stubs_shared.%.$(O): OC_CPPFLAGS += -DSYSTHREADS_SHARED

ifeq "$(COMPUTE_DEPS)" "true"
st_stubs.%.$(O): st_stubs.c
st_stubs%.$(O): st_stubs.c
else
st_stubs.%.$(O): st_stubs.c $(RUNTIME_HEADERS) $(wildcard *.h)
st_stubs%.$(O): st_stubs.c $(RUNTIME_HEADERS) $(wildcard *.h)
endif
$(V_CC)$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS) \
$(OUTPUTOBJ)$@ -c $<
Expand Down Expand Up @@ -121,6 +129,9 @@ installopt:
$(INSTALL_DATA) \
$(THREADS_NCOBJS) threads.cmxa threads.$(A) \
"$(INSTALL_THREADSLIBDIR)"
ifeq "$(NATDYNLINK)" "true"
$(INSTALL_PROG) $(LIBNAME).cmxs "$(INSTALL_THREADSLIBDIR)"
endif

%.cmi: %.mli
$(V_OCAMLC)$(CAMLC) -c $(COMPFLAGS) $<
Expand Down
7 changes: 2 additions & 5 deletions otherlibs/systhreads/st_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@

#define CAML_INTERNALS

#if defined(_WIN32) && !defined(NATIVE_CODE) && !defined(_MSC_VER)
#if defined(_WIN32) && defined(SYSTHREADS_SHARED)
/* Ensure that pthread.h marks symbols __declspec(dllimport) so that they can be
picked up from the runtime (which will have linked winpthreads statically).
mingw-w64 11.0.0 introduced WINPTHREADS_USE_DLLIMPORT to do this explicitly;
prior versions co-opted this on the internal DLL_EXPORT, but this is ignored
in 11.0 and later unless IN_WINPTHREAD is also defined, so we can safely
define both to support both versions.
When compiling with MSVC, we currently link directly the winpthreads objects
into our runtime, so we do not want to mark its symbols with
__declspec(dllimport). */
define both to support both versions. */
#define WINPTHREADS_USE_DLLIMPORT
#define DLL_EXPORT
#endif
Expand Down
Loading
Loading