Open selfisekai opened 1 year ago
//cc @athomas @rmacnak-google
It is possible to select the sysroot using existing flags:
tools/build.py --no-goma --no-clang --arch=x64 --target-sysroot=x64=/ --gn-args "dart_use_tcmalloc=false" create_sdk
@rmacnak-google this does not indicate the libc we're compiling for by itself. I still need a few quickfixes like this in gn to compile on/for alpine host:
--- ./build/config/compiler/BUILD.gn.orig
+++ ./build/config/compiler/BUILD.gn
@@ -258,7 +258,7 @@
# ------------------------------------
if (is_linux) {
if (is_clang) {
- if (dart_sysroot == "alpine") {
+ if (true) {
# alpine linux target names can be found at:
# https://pkgs.alpinelinux.org/contents?file=stdc%2B%2B.h&name=libstdc%2B%2B-dev
if (current_cpu == "arm") {
@@ -672,10 +672,6 @@
"-Wextra",
]
- if (dart_sysroot != "alpine") {
- cflags += [ "-Werror" ]
- }
-
defines = []
if (!using_sanitizer && !is_clang) {
# _FORTIFY_SOURCE isn't really supported by Clang now, see
It works for me with the bootlin toolchains (on a Debian host).
$ build() { ./tools/build.py --no-goma --no-clang --gn-args=dart_use_tcmalloc=false --gn-args=dart_sysroot=\"\" --mode=release $@ create_sdk runtime ; }
$ build --arch=x64 --toolchain=x64=$HOME/toolchains/x86-64--musl--stable-2022.08-1/bin/x86_64-buildroot-linux-musl-
$ build --arch=arm64 --toolchain=arm64=$HOME/toolchains/aarch64--musl--stable-2022.08-2/bin/aarch64-buildroot-linux-musl-
$ build --arch=riscv64 --toolchain=riscv64=$HOME/toolchains/riscv64-lp64d--musl--stable-2022.08-1/bin/riscv64-buildroot-linux-musl-
$ docker run --mount type=bind,source=$PWD/out/ReleaseX64/dart-sdk,target=/dart-sdk alpine /dart-sdk/bin/dart --version
Dart SDK version: 3.1.0-edge.d8b53d97ffedfa33775e401ea0eb69d9cdded3eb (be) (Thu Apr 13 16:45:14 2023 +0000) on "linux_x64"
@rmacnak-google here's on my machine: alpine x64 host, gclient-provided clang/gn/ninja replaced with symlinks to system ones
./tools/build.py --no-goma --no-clang --gn-args=dart_use_tcmalloc=false --gn-args=dart_sysroot=\"\" --mode=release --arch=x64 create_sdk runtime
- working (well, fails later for bootstrap reasons)
not working because of invalid target provided:
dart_sysroot == "alpine"
: https://github.com/dart-lang/sdk/blob/90d84c849472b375e0fbb7321f800208180cd14b/build/config/compiler/BUILD.gn#L297
$ ./tools/build.py --no-goma --clang --gn-args=dart_use_tcmalloc=false --gn-args=dart_sysroot=\"\" --mode=release --arch=x64 create_sdk runtime
ninja: job failed: ../../buildtools/linux-x64/clang/bin/clang++ -MMD -MF obj/runtime/vm/compiler/libdart_compiler_precompiler_testing.method_recognizer.o.d -DTOOLCHAIN_VERSION=system -DNDEBUG -DTARGET_ARCH_X64 -DDART_TARGET_OS_LINUX -DDART_PRECOMPILER -DTESTING -I../../runtime -I../.. -Igen -I../../runtime/include -m64 -march=x86-64 -msse2 -fPIE --target=x86_64-linux-gnu -fcolor-diagnostics -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-tautological-constant-compare -Wno-unused-but-set-variable -Wno-deprecated-non-prototype -fdebug-prefix-map=/home/lauren/dart/sdk=../.. -no-canonical-prefixes -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wheader-hygiene -Wstring-conversion -O2 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -fno-strict-vtable-pointers -O2 -fno-omit-frame-pointer -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++17 -fno-rtti -c ../../runtime/vm/compiler/method_recognizer.cc -o obj/runtime/vm/compiler/libdart_compiler_precompiler_testing.method_recognizer.o In file included from ../../runtime/vm/compiler/method_recognizer.cc:5: In file included from ../../runtime/vm/compiler/method_recognizer.h:8: In file included from ../../runtime/vm/allocation.h:8: In file included from ../../runtime/platform/allocation.h:8: In file included from ../../runtime/platform/address_sanitizer.h:8: ../../runtime/platform/globals.h:92:10: fatal error: 'cassert' file not found
^~~~~~~~~
1 error generated.
2. anything other than x64 or x86 with gcc (would fail no matter if cross or not) - workaround available by `--gn-args='arm64_toolchain_prefix="aarch64-linux-musl-"'` and so on for each architecture - defined by `prefix` here: https://github.com/dart-lang/sdk/blob/90d84c849472b375e0fbb7321f800208180cd14b/build/toolchain/linux/BUILD.gn
$ ./tools/build.py --no-goma --no-clang --gn-args=dart_use_tcmalloc=false --gn-args=dart_sysroot=\"\" --mode=release --arch=arm64 create_sdk runtime
ninja: job failed: aarch64-linux-gnu-g++ -MMD -MF obj/runtime/vm/compiler/libdart_compiler_precompiler.write_barrier_elimination.o.d -D_FORTIFY_SOURCE=2 -DNDEBUG -DTARGET_ARCH_ARM64 -DDART_TARGET_OS_LINUX -DDART_PRECOMPILER -I../../runtime -I../.. -Igen -I../../runtime/include -fPIE -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-ignored-qualifiers -fdebug-prefix-map=/home/lauren/dart/sdk=../.. -no-canonical-prefixes -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O2 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wno-cast-function-type -O2 -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++17 -fno-rtti -c ../../runtime/vm/compiler/write_barrier_elimination.cc -o obj/runtime/vm/compiler/libdart_compiler_precompiler.write_barrier_elimination.o /bin/sh: aarch64-linux-gnu-g++: not found
there are some gn changes needed to compile for musl. currently, dart detects musl by
dart_sysroot == "alpine"
, but that doesn't work when simply compiling for musl on a musl host.I've submitted this PR into flutter: https://github.com/flutter/buildroot/pull/707 - any comments? I'm hoping for a universal approach for this in dart and flutter