AOSP Master won't build, what am I doing wrong?

I got this to build in the past, but now whenever I try to build master branch I get:

[ 0% 8/75932] host C++: libadb <= system/core/adb/sockets.cpp
FAILED: out/host/linux-x86/obj/STATIC_LIBRARIES/libadb_intermediates/sockets.o
/bin/bash -c “PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++ -I system/core/adb -I out/host/linux-x86/obj/STATIC_LIBRARIES/libadb_intermediates -I out/host/linux-x86/gen/STATIC_LIBRARIES/libadb_intermediates -I libnativehelper/include_deprecated $(cat out/host/linux-x86/obj/STATIC_LIBRARIES/libadb_intermediates/import_includes) -I system/core/include -I system/media/audio/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I libnativehelper/include -I frameworks/native/include -I frameworks/native/opengl/include -I frameworks/av/include -c -Wa,–noexecstack -fPIC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -fstack-protector-strong -m64 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g -fno-strict-aliasing -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-expansion-to-defined -Wno-zero-as-null-pointer-constant -fdebug-prefix-map=$PWD/= -target x86_64-linux-gnu -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin -Wsign-promo -Wno-inconsistent-missing-override -Wno-null-dereference -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-thread-safety-negative -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8 -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8/backward -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8/x86_64-linux -std=gnu++14 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wvla -DADB_VERSION=”\“27.0.0-$(cat out/build_number.txt)\”" -fvisibility=hidden -DADB_HOST=1 -fPIC -Wexit-time-destructors -Wthread-safety -D_USING_LIBCXX -DANDROID_STRICT -nostdinc++ -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type -MD -MF out/host/linux-x86/obj/STATIC_LIBRARIES/libadb_intermediates/sockets.d -o out/host/linux-x86/obj/STATIC_LIBRARIES/libadb_intermediates/sockets.o system/core/adb/sockets.cpp"
python: can’t open file ‘prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++’: [Errno 2] No such file or directory
ninja: build stopped: subcommand failed.
16:08:00 ninja failed with: exit status 1

failed to build some targets (9 seconds)

This makes no sense. First off the file does exist:

mike@mike-Z87-D3HP:/mnt/AOSP-master$ ls -la prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++
-rwxrwxr-x 1 mike mike 6398 Nov 16 13:10 prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++

And secondly, why is python throwing the error? I don’t see python in that command line at all. (I could be blind…)

I try to manually run the full command by hand and get the same error, but if I run “prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++” I get the expected no input files error.

What gives? Any ideas?


OK I think I figured out how to fix the issue. In this case python was the clang++ executable, and it could not find itself…

To fix it I did this:

mike@Scorpius:~/devel/android/AOSP/build/core$ git diff
diff --git a/core/ b/core/
index 0d25afe…fa970b1 100644
— a/core/
+++ b/core/
@@ -783,7 +783,7 @@ BUILD_DATETIME_FROM_FILE := $$(cat $(OUT_DIR)/build_date.txt)

directories will create the same output.

/proc doesn’t exist on Darwin.

ifeq ($(HOST_OS),linux)
-RELATIVE_PWD := PWD=/proc/self/cwd
+RELATIVE_PWD := #PWD=/proc/self/cwd

So far it is compiling ok…

More to add… Found one more place to change:

mike@Scorpius:~/devel/android/AOSP/build/soong$ git diff
diff --git a/cc/builder.go b/cc/builder.go
index a81dc89…4a1e203 100644
— a/cc/builder.go
+++ b/cc/builder.go
@@ -215,7 +215,8 @@ func init() {
// debug output. That way two builds in two different directories will
// create the same output.
if runtime.GOOS != “darwin” {

  •           pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
  •           //pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
  •           pctx.StaticVariable("relPwd", "")
      } else {
              // Darwin doesn't have /proc
              pctx.StaticVariable("relPwd", "")

you could be between merges, I did a build this morning(although for a separate board) and it runs fine. Best option is to wait for a few minutes/hours and run “repo sync” again.

it is less probable for issues to appear in build/core or buinld/soong.

AFAIK python is used more or less as a script to assist in the build process

Well, the issue still persists. After several syncs and even a complete re-download of everything, even tried on 2 separate computers.

I can reproduce the error by just doing:

/bin/bash -c “PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++”

from the root of the AOSP tree. Is this maybe an issue with Ubuntu 16.04?

If I do:

/bin/bash -c “PWD=pwd prebuilts/clang/host/linux-x86/clang-4393122/bin/clang++”

I get the expected response…


Edit: pwd above should have backtics around it, but the board is stripping them…

I built it fresh yesterday, I am not seeing any issues. Using Ubuntu 16.04
are you running $ source build/ and $ lunch

I’ve been doing

. ./build/; lunch hikey-userdebug

Isn’t that the same?


yes, it is.
It really seems to be an issue with your ubuntu installation, I did a build again last night, seems to be working fine

whats the output for ls -al /proc/self/cwd
run this inside the aosp source folder

Here ya go:

mike@mike-Z87-D3HP:/media/mike/dc378fb0-a1d4-4a63-89a8-7ec22430a1c1/AOSP-master$ ls -al /proc/self/cwd
lrwxrwxrwx 1 mike mike 0 Dec 13 14:44 /proc/self/cwd -> /media/mike/dc378fb0-a1d4-4a63-89a8-7ec22430a1c1/AOSP-master


This is still an issue. I have no idea why. I can build the 8.1.0-r14 branch fine without this issue but if I try to build master no dice.

What shell are you using @loic ?

Any suggestions?


Did you re-sync the repo against the master between build attempts? (I guess you probably did but just want to check this wasn’t just a transient build regression on master that has since been fixed).

This was from a fresh checkout. So initial sync.


This is most likely an issue with your environment since no one reproduce this error. I can suggest you to try with an other machine or using container (LXC/docker) to build in a clean environment. (e.g.

I’ve actually tried on 2 different Ubuntu 16.04 machines and both have the same issue.

I will try in the docker container like you suggest.


For your interest, I’ve just pushed an up-to-date docker here:, I have been able to build AOSP master for both Hikey and Hikey-960. Container is based on ubuntu 18.04.