## backend-per-platform.pkg
## (C) 1999 Lucent Technologies, Bell Laboratories
## Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
# Compiled by:
#
src/app/makelib/makelib.sublib# On-demand loading, caching and invocation
# of platform-specific compilers.
#
#
# In directory
#
# src/lib/core/mythryl-compiler-compiler
#
# we define compiler-compilers for a number of platforms:
#
# mythryl-compiler-compiler-for-pwrpc32-macos.lib
# mythryl-compiler-compiler-for-pwrpc32-posix.lib
# mythryl-compiler-compiler-for-sparc32-posix.lib
# mythryl-compiler-compiler-for-intel32-posix.lib
# mythryl-compiler-compiler-for-intel32-win32.lib
#
# Rather than have all of these in memory at all times
# in the compile servers, we load them one at a time in
# response to specific requests.
#
# Here we invoke a requested backend, first (compiling
# and thus loading) it if necessary.
#
# The net result of this chicanery is that backend compilations
# get invoked by the sequence (essentially)
#
# backend_per_platform::invoke which calls # backend_per_platform is from
src/app/makelib/mythryl-compiler-compiler/backend-per-platform.pkg# backend_index::invoke which calls #
# mythryl_compiler_compiler_g::make_mythryl_compiler # mythryl_compiler_compiler_g is from
src/app/makelib/mythryl-compiler-compiler/mythryl-compiler-compiler-g.pkgstipulate
package ss = string_set; # string_set is from
src/lib/src/string-set.pkg package bi = backend_index; # backend_index is from
src/app/makelib/mythryl-compiler-compiler/backend-index.pkgherein
package backend_per_platform {
# ====================
stipulate
# This is a set of strings like
# $ROOT/
src/lib/core/mythryl-compiler-compiler/mythryl-compiler-compiler-for-intel32-posix.lib #
loaded_platforms = REF ss::empty; # Remember which target compilers we already have in memory.
herein
fun invoke
make # This is the standard 'make' entrypoint into
src/app/makelib/main/makelib-g.pkg platform # 'platform' string is architecture+OS, e.g. "intel32-linux"
backend_request # See Backend_Request comments in
src/app/makelib/mythryl-compiler-compiler/backend-index.pkg =
{ platform_specific_backend_makefile
=
cat ["$ROOT/src/lib/core/mythryl-compiler-compiler/", platform, ".lib"]; # Eg. intel32-posix -> $ROOT/
src/lib/core/mythryl-compiler-compiler/mythryl-compiler-compiler-for-intel32-posix.lib if (not (ss::member (*loaded_platforms, platform_specific_backend_makefile)))
#
if (make platform_specific_backend_makefile)
#
loaded_platforms
:=
ss::add (*loaded_platforms, platform_specific_backend_makefile);
else
raise exception DIE (
sprintf "dynamic linkage of %s platform-specific backend '%s' failed"
platform
platform_specific_backend_makefile
);
fi;
fi;
# The desired platform-specific backend is now
# in memory, and as part of the process of loading it,
#
#
src/app/makelib/mythryl-compiler-compiler/mythryl-compiler-compiler-g.pkg #
# will have registered a compile function for it,
# which we now invoke:
#
bi::invoke platform backend_request;
#
# 'platform' string is architecture+OS, e.g. "intel32-linux"
# For 'backend_request' see Backend_Request comments in
src/app/makelib/mythryl-compiler-compiler/backend-index.pkg };
end;
};
end;