Repository: flutter
Issue: Problems compiling flutter engine for x86 embedded linux environment (with target-sysroot option)
Labels: engine,platform-linux,P2,team-engine,triaged-engine

I can not   compile flutter engine for x86 (i386) architecture for external rootfs

The error is the following:
```
In file included from ../../third_party/dart/runtime/vm/cpu_ia32.cc:11:
../../third_party/dart/runtime/vm/compiler/assembler/assembler.h:9:2: error: "AOT runtime should not use compiler sources (including header files)"
#error "AOT runtime should not use compiler sources (including header files)"
```
I'm following these steps (as described at  https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment, https://github.com/flutter/flutter/wiki/Compiling-the-engine):
a) Install build tools and google repo tools 
a) Fork flutter/engine ( github.com/YuryAdamov/engine)
b) Create directory engine with .gclient 
```
solutions = [
  {
    "managed": False,
    "name": "src/flutter",
    "url": "git@github.com:<your_name_here>/engine.git",
    "custom_deps": {},
    "deps_file": "DEPS",
    "safesync_url": "",
  },
]
```
c) gclient sync
d) create debian rootfs
``` 
mkdir debian_sysroot
sudo debootstrap --arch i386 --foreign --keyring=./debian-release-10.gpg --include=libfreetype6-dev buster debian_sysroot
sudo chroot debian_sysroot/ /debootstrap/debootstrap --second-stage
```
d) run gn
```
PKG_CONFIG_PATH=/home/user/build/debian_sysroot/usr/lib/i386-linux-gnu/pkgconfig/ ./flutter/tools/gn --runtime-mode jit_release --embedder-for-target --target-os linux --linux-cpu x86 --target-sysroot /home/user/build/debian_sysroot/ --disable-desktop-embeddings  --target-toolchain /usr --target-triple i386-linux-gnu
```
For some reason running without PKG_CONFIG_PATH option doesn't find freetype2 in pkgconfig
e) ninja -C out/linux_jit_release_x86

This produces the following error

```
[15/5231] CXX obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.cpu_ia32.o
FAILED: obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.cpu_ia32.o
/usr/bin/clang++ -MD -MF obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.cpu_ia32.o.d --target=i386-linux-gnu --sysroot /home/user/build/debian_sysroot/ -DUSE_OPENSSL=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORM
AT_MACROS -D_LIBCPP_DISABLE_AVAILABILITY=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DNDEBUG -DNVALGRIND -DDYNAMIC_
ANNOTATIONS_ENABLED=0 -DTARGET_ARCH_IA32 -DNDEBUG -DTARGET_OS_LINUX -DDART_PRECOMPILED_RUNTIME -DEXCLUDE_CFE_AND_KERNEL_PLATFORM -DPRODUCT -DU_USING_ICU_NAMES
PACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DAT
A_FILE -DUCHAR_TYPE=uint16_t -I../../third_party/dart/runtime -I../.. -Igen -I../../third_party/libcxx/include -I../../third_party/libcxxabi/include -I../../t
hird_party/libcxxabi/include -I../../third_party/dart/runtime/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -fno-strict-al
iasing -fstack-protector --param=ssp-buffer-size=4 -m32 -mstack-alignment=16 -mstackrealign -fPIC -pipe -pthread -fcolor-diagnostics -Wall -Wextra -Wendif-lab
els -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-non-c-typedef-for-linkage -Wno-d
eprecated-copy -Wno-range-loop-construct -fvisibility=hidden --sysroot=/home/zodiac_ui/build/flutter_selene2/debian_sysroot/ -Wstring-conversion -Wnewline-eof
 -O2 -fno-ident -fdata-sections -ffunction-sections -g0 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverl
oaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++17 -fno-rt
ti -nostdinc++ -nostdinc++ -fno-exceptions -c ../../third_party/dart/runtime/vm/cpu_ia32.cc -o obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_
product.cpu_ia32.o
In file included from ../../third_party/dart/runtime/vm/cpu_ia32.cc:11:
../../third_party/dart/runtime/vm/compiler/assembler/assembler.h:9:2: error: "AOT runtime should not use compiler sources (including header files)"
#error "AOT runtime should not use compiler sources (including header files)"
 ^
In file included from ../../third_party/dart/runtime/vm/cpu_ia32.cc:11:
In file included from ../../third_party/dart/runtime/vm/compiler/assembler/assembler.h:21:
../../third_party/dart/runtime/vm/compiler/assembler/assembler_ia32.h:9:2: error: "AOT runtime should not use compiler sources (including header files)"
#error "AOT runtime should not use compiler sources (including header files)"
 ^
In file included from ../../third_party/dart/runtime/vm/cpu_ia32.cc:11:
In file included from ../../third_party/dart/runtime/vm/compiler/assembler/assembler.h:21:
In file included from ../../third_party/dart/runtime/vm/compiler/assembler/assembler_ia32.h:18:
../../third_party/dart/runtime/vm/compiler/assembler/assembler_base.h:9:2: error: "AOT runtime should not use compiler sources (including header files)"
#error "AOT runtime should not use compiler sources (including header files)"
 ^
3 errors generated.
[22/5231] CXX obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.dart.o
FAILED: obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.dart.o
/usr/bin/clang++ -MD -MF obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.dart.o.d --target=i386-linux-gnu --sysroot /home/user/bui
ld/debian_sysroot/ -DUSE_OPENSSL=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_M
ACROS -D_LIBCPP_DISABLE_AVAILABILITY=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNO
TATIONS_ENABLED=0 -DTARGET_ARCH_IA32 -DNDEBUG -DTARGET_OS_LINUX -DDART_PRECOMPILED_RUNTIME -DEXCLUDE_CFE_AND_KERNEL_PLATFORM -DPRODUCT -DU_USING_ICU_NAMESPACE
=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=uint16_t -I../../third_party/dart/runtime -I../.. -Igen -I../../third_party/libcxx/include -I../../third_party/libcxxabi/include -I../../third_party/libcxxabi/include -I../../third_party/dart/runtime/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -fno-strict-aliasing -fstack-protector --param=ssp-buffer-size=4 -m32 -mstack-alignment=16 -mstackrealign -fPIC -pipe -pthread -fcolor-diagnostics -Wall -Wextra -Wendif-labels -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-non-c-typedef-for-linkage -Wno-deprecated-copy -Wno-range-loop-construct -fvisibility=hidden --sysroot=/home/zodiac_ui/build/flutter_selene2/debian_sysroot/ -Wstring-conversion -Wnewline-eof -O2 -fno-ident -fdata-sections -ffunction-sections -g0 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fno-exceptions -c ../../third_party/dart/runtime/vm/dart.cc -o obj/third_party/dart/runtime/vm/libdart_vm_precompiled_runtime_product.dart.o
../../third_party/dart/runtime/vm/dart.cc:150:36: error: use of undeclared identifier 'AOT_ObjectPool_elements_start_offset'; did you mean 'ObjectPool_elements_start_offset'?
  COMMON_OFFSETS_LIST(CHECK_FIELD, CHECK_ARRAY, CHECK_SIZEOF,
                                   ^
../../third_party/dart/runtime/vm/compiler/runtime_offsets_extracted.h:3115:47: note: 'ObjectPool_elements_start_offset' declared here
static constexpr dart::compiler::target::word ObjectPool_elements_start_offset =
                                              ^
../../third_party/dart/runtime/vm/dart.cc:150:36: error: use of undeclared identifier 'AOT_ObjectPool_elements_start_offset'; did you mean 'ObjectPool_elements_start_offset'?
  COMMON_OFFSETS_LIST(CHECK_FIELD, CHECK_ARRAY, CHECK_SIZEOF,
                                   ^
../../third_party/dart/runtime/vm/compiler/runtime_offsets_extracted.h:3115:47: note: 'ObjectPool_elements_start_offset' declared here
static constexpr dart::compiler::target::word ObjectPool_elements_start_offset =
                                              ^
../../third_party/dart/runtime/vm/dart.cc:150:36: error: use of undeclared identifier 'AOT_ObjectPool_element_size'; did you mean 'ObjectPool_element_size'?
```