diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2009-03-31 18:02:12 +0300 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2009-03-31 19:14:55 +0300 |
commit | 86e0e47bc9706567c44f9ee48badd4f299bb7eed (patch) | |
tree | c3ec1e18887d35e258260ae8e8ee6eae394aadf1 | |
parent | c6e2b12d9896fef56ad0a0f72d57005f08137ab3 (diff) |
Added "nomap" mapping mode: SB2 can now be used to do native builds, too!
- "nomap" mode passes all paths, execs, etc. thru the logic in our
preload library, but does not map anything. This is mostly useful for
debugging SB2 itself, but can be used for benchmarking etc. also.
- Had to add a new option to sb2-init, otherwise "nomap" mode could not
be properly initialized on 64-bit intel hosts.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | lua_scripts/pathmaps/nomap/00_default.lua | 68 | ||||
-rwxr-xr-x | utils/sb2-init | 13 | ||||
-rwxr-xr-x | utils/sb2-parse-sb2-init-args | 4 |
4 files changed, 85 insertions, 2 deletions
@@ -130,6 +130,7 @@ install-noarch: regular $(Q)install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/tools $(Q)install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/simple $(Q)install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/devel + $(Q)install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/nomap $(Q)install -d -m 755 $(prefix)/share/scratchbox2/lua_scripts/pathmaps/install # "scripts" and "wrappers" are visible to the user in some @@ -175,6 +176,7 @@ install-noarch: regular $(Q)install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/tools/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/tools/ $(Q)install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/simple/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/simple/ $(Q)install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/devel/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/devel/ + $(Q)install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/nomap/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/nomap/ $(Q)install -c -m 644 $(SRCDIR)/lua_scripts/pathmaps/install/*.lua $(prefix)/share/scratchbox2/lua_scripts/pathmaps/install/ $(Q)(set -e; cd $(prefix)/share/scratchbox2/lua_scripts/pathmaps; ln -sf devel maemo) diff --git a/lua_scripts/pathmaps/nomap/00_default.lua b/lua_scripts/pathmaps/nomap/00_default.lua new file mode 100644 index 0000000..7f955bb --- /dev/null +++ b/lua_scripts/pathmaps/nomap/00_default.lua @@ -0,0 +1,68 @@ +-- Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org> +-- Copyright (C) 2007 Nokia Corporation. +-- Licensed under MIT license. + +-- "nomap" mapping mode: Does not map any paths anywhere, but still pushes +-- all paths thru SB2's path mapping logic, handles execs, etc. +-- +-- This is useful for benchmarking, debugging (SB2's logs are available, if +-- needed), and of course this makes SB2 fully symmetric because now SB2 +-- can be used both for cross-compiling and for native builds! :-) ;-) +-- +-- Note that the target architecture should be set to host architecture +-- while using this mode; usually a special "nomap" target should be created. +-- Example: +-- for 64-bit intel/amd architectures ("uname -m" displays "x86_64"): +-- sb2-init -A amd64 -M x86_64 -n -m nomap nomap +-- Next, use "sb2 -t nomap" to enter this mode (i.e. things usually go wrong +-- if you try to use the the "-m" option to enter this mode, but the target +-- is still something else than the host. The destination architecture is not +-- selected by the mapping mode...) + +-- Rule file interface version, mandatory. +-- +rule_file_interface_version = "21" +---------------------------------- + +-- disable the gcc toolchain tricks. +enable_cross_gcc_toolchain = false + +nomap_chain = { + next_chain = nil, + binary = nil, + rules = { + -- Don't map. + {prefix = "/", use_orig_path = true}, + } +} + +export_chains = { + nomap_chain +} + +-- Exec policy rules. + +default_exec_policy = { + name = "Default" +} + +-- Note that the real path (mapped path) is used when looking up rules! +all_exec_policies_chain = { + next_chain = nil, + binary = nil, + rules = { + -- DEFAULT RULE (must exist): + {prefix = "/", exec_policy = default_exec_policy} + } +} + +exec_policy_chains = { + all_exec_policies_chain +} + +-- This table lists all exec policies - this is used when the current +-- process wants to locate the currently active policy +all_exec_policies = { + default_exec_policy, +} + diff --git a/utils/sb2-init b/utils/sb2-init index b556f11..ef4c698 100755 --- a/utils/sb2-init +++ b/utils/sb2-init @@ -81,6 +81,8 @@ Options: -C "options" add extra options for the compiler, for example: "-fgnu89-inline" -A arch manually override target architecture + -M arch manually override machine name (see uname(2)). This + defaults to the target architecture (see option -A) -v display version Examples: @@ -117,7 +119,7 @@ SBOX_TARGET_ROOT=$SBOX_TARGET_ROOT SBOX_CPU=$ARCH SBOX_CPUTRANSPARENCY_METHOD="$SB2INIT_CPUTRANSP" -SBOX_UNAME_MACHINE=$ARCH +SBOX_UNAME_MACHINE=$MACHINE_ARCH DEB_BUILD_ARCH=$SB2INIT_DEB_BUILD_ARCH DEB_BUILD_ARCH_CPU=$SB2INIT_DEB_BUILD_ARCH_CPU @@ -317,6 +319,14 @@ else fi echo "sb2-init: Target architecture is '$ARCH'" +if [ -z "$SB2INIT_MACHINE_ARCH" ]; then + MACHINE_ARCH=$ARCH +else + # forced by a command-line option. + MACHINE_ARCH=$SB2INIT_MACHINE_ARCH + echo "sb2-init: Target machine is '$SB2INIT_MACHINE_ARCH'" +fi + DEBIAN_CPU=$ARCH HOST_ARCH="$(uname -m)" @@ -349,6 +359,7 @@ case "$ARCH" in i486*) ;; i586*) ;; i686*) ;; + amd64*) ;; *) echo "Unsupported target architecture: '$ARCH'" echo "You must add support for it into preload/sb_exec.c" diff --git a/utils/sb2-parse-sb2-init-args b/utils/sb2-parse-sb2-init-args index 2f7e86f..2d630ea 100755 --- a/utils/sb2-parse-sb2-init-args +++ b/utils/sb2-parse-sb2-init-args @@ -22,10 +22,11 @@ SB2INIT_SHOW_VERSION=0 SB2INIT_ERROR=0 # Parse the same options what sb2-init uses: -while getopts A:c:C:r:l:m:dhnNst:v foo +while getopts A:M:c:C:r:l:m:dhnNst:v foo do case $foo in (A) SB2INIT_ARCH=$OPTARG ;; + (M) SB2INIT_MACHINE_ARCH=$OPTARG ;; (c) SB2INIT_CPUTRANSP=$OPTARG ;; (r) SB2INIT_REMOTEHOST=$OPTARG ;; (l) SB2INIT_LOCALHOST=$OPTARG ;; @@ -68,6 +69,7 @@ SB2INIT_INIT_ID="$SBOX_INIT_ID" SB2INIT_TARGET_ROOT="$SB2INIT_TARGET_ROOT" SB2INIT_ARCH="$SB2INIT_ARCH" +SB2INIT_MACHINE_ARCH="$SB2INIT_MACHINE_ARCH" SB2INIT_CPUTRANSP="$SB2INIT_CPUTRANSP" SB2INIT_REMOTEHOST="$SB2INIT_REMOTEHOST" SB2INIT_LOCALHOST="$SB2INIT_LOCALHOST" |