summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-05-31 14:29:22 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-05-31 18:13:43 +0200
commit9e45d1525b0fde12a08f7c376b5bf2c7bfbc9803 (patch)
tree2d0fd5e44999e7242fc22efaae1d8d25eb5ec59a
parentea4ebc8b7eda78d993d67f5fffbcf2eb19690899 (diff)
downloadjustbuild-9e45d1525b0fde12a08f7c376b5bf2c7bfbc9803.tar.gz
Support FINAL_LDFLAGS variable for binaries
... and set default stack size to 8 MB.
-rw-r--r--INSTALL.md6
-rw-r--r--TARGETS4
-rwxr-xr-xbin/bootstrap.py7
-rw-r--r--src/buildtool/main/TARGETS14
-rw-r--r--src/other_tools/just_mr/TARGETS14
5 files changed, 34 insertions, 11 deletions
diff --git a/INSTALL.md b/INSTALL.md
index e9da7f59..86a23467 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -22,7 +22,7 @@ specify `arm64` as the target architecture via the `-D` flag:
just-mr build -D '{"TARGET_ARCH":"arm64"}'
```
-The following table descries the most important supported configuration
+The following table describes the most important supported configuration
variables. The full list can be obtained via `just-mr describe`.
|Variable|Supported Values|Default Value for `just`|
@@ -35,6 +35,10 @@ variables. The full list can be obtained via `just-mr describe`.
| DEBUG | true, false | false |
| BUILD_STATIC_BINARY | true, false | false |
+Note that you can choose a different stack size for resulting binaries by
+adding `"-Wl,-z,stack-size=<size-in-bytes>"` to variable `"FINAL_LDFLAGS"`
+(which has to be a list of strings).
+
## Bootstrapping `just`
It is also possible to build `just` without having an older binary,
diff --git a/TARGETS b/TARGETS
index ad114865..108a285f 100644
--- a/TARGETS
+++ b/TARGETS
@@ -8,6 +8,7 @@
, "AR"
, "ARCH"
, "BUILD_STATIC_BINARY"
+ , "FINAL_LDFLAGS"
, "CC"
, "COMPILER_FAMILY"
, "CXX"
@@ -45,6 +46,7 @@
, "BUILD_STATIC_BINARY":
[ "Boolean, default false. If set, try to build a (mainly) static binary."
]
+ , "FINAL_LDFLAGS": ["Compiler flags for linking the final binary."]
, "DEBUG": ["Boolean, default false. Whether to build a debug version."]
, "OS":
[ "Operating system to build for."
@@ -83,6 +85,7 @@
, "AR"
, "ENV"
, "BUILD_STATIC_BINARY"
+ , "FINAL_LDFLAGS"
, "SOURCE_DATE_EPOCH"
, "VERSION_EXTRA_SUFFIX"
, "PKG_CONFIG_ARGS"
@@ -139,6 +142,7 @@
, "AR"
, "ENV"
, "BUILD_STATIC_BINARY"
+ , "FINAL_LDFLAGS"
, "SOURCE_DATE_EPOCH"
, "VERSION_EXTRA_SUFFIX"
]
diff --git a/bin/bootstrap.py b/bin/bootstrap.py
index e235aa0d..012f0d67 100755
--- a/bin/bootstrap.py
+++ b/bin/bootstrap.py
@@ -85,6 +85,7 @@ CC="cc"
CXX="c++"
CFLAGS = []
CXXFLAGS = []
+FINAL_LDFLAGS = ["-Wl,-z,stack-size=8388608"]
if "COMPILER_FAMILY" in CONF:
if CONF["COMPILER_FAMILY"] == "gnu":
@@ -104,6 +105,8 @@ if "ADD_CFLAGS" in CONF:
CFLAGS=CONF["ADD_CFLAGS"]
if "ADD_CXXFLAGS" in CONF:
CXXFLAGS=CONF["ADD_CXXFLAGS"]
+if "FINAL_LDFLAGS" in CONF:
+ FINAL_LDFLAGS+=CONF["FINAL_LDFLAGS"]
BOOTSTRAP_CC = [CXX] + CXXFLAGS + ["-std=c++20", "-DBOOTSTRAP_BUILD_TOOL"]
@@ -371,8 +374,8 @@ def bootstrap():
cmd = BOOTSTRAP_CC + flags + ["-c", f, "-o", obj_file_name]
ts.submit(run, cmd, cwd=src_wrkdir)
bootstrap_just = os.path.join(WRKDIR, "bootstrap-just")
- cmd = BOOTSTRAP_CC + ["-o", bootstrap_just
- ] + object_files + dep_flags["link"]
+ cmd = BOOTSTRAP_CC + FINAL_LDFLAGS + ["-o", bootstrap_just
+ ] + object_files + dep_flags["link"]
run(cmd, cwd=src_wrkdir)
CONF_FILE = os.path.join(WRKDIR, "repo-conf.json")
LOCAL_ROOT = os.path.join(WRKDIR, ".just")
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS
index 68197a89..52a92521 100644
--- a/src/buildtool/main/TARGETS
+++ b/src/buildtool/main/TARGETS
@@ -1,6 +1,6 @@
{ "just":
{ "type": ["@", "rules", "CC", "binary"]
- , "arguments_config": ["BUILD_STATIC_BINARY"]
+ , "arguments_config": ["BUILD_STATIC_BINARY", "FINAL_LDFLAGS"]
, "name": ["just"]
, "srcs": ["main.cpp"]
, "private-deps":
@@ -31,9 +31,15 @@
]
, "stage": ["src", "buildtool", "main"]
, "private-ldflags":
- { "type": "if"
- , "cond": {"type": "var", "name": "BUILD_STATIC_BINARY"}
- , "then": ["-static"]
+ { "type": "++"
+ , "$1":
+ [ ["-Wl,-z,stack-size=8388608"]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "BUILD_STATIC_BINARY"}
+ , "then": ["-static"]
+ }
+ , {"type": "var", "name": "FINAL_LDFLAGS", "default": []}
+ ]
}
}
, "describe":
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS
index 85b86f53..02876feb 100644
--- a/src/other_tools/just_mr/TARGETS
+++ b/src/other_tools/just_mr/TARGETS
@@ -1,6 +1,6 @@
{ "just-mr":
{ "type": ["@", "rules", "CC", "binary"]
- , "arguments_config": ["BUILD_STATIC_BINARY"]
+ , "arguments_config": ["BUILD_STATIC_BINARY", "FINAL_LDFLAGS"]
, "name": ["just-mr"]
, "srcs": ["main.cpp"]
, "private-deps":
@@ -22,9 +22,15 @@
]
, "stage": ["src", "other_tools", "just_mr"]
, "private-ldflags":
- { "type": "if"
- , "cond": {"type": "var", "name": "BUILD_STATIC_BINARY"}
- , "then": ["-static"]
+ { "type": "++"
+ , "$1":
+ [ ["-Wl,-z,stack-size=8388608"]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "BUILD_STATIC_BINARY"}
+ , "then": ["-static"]
+ }
+ , {"type": "var", "name": "FINAL_LDFLAGS", "default": []}
+ ]
}
}
, "utils":