Commit graph

52 commits

Author SHA1 Message Date
Dan Willemsen
056609ccfe Remove unnecessary variables
These are all either recently unused due to the removal of CFLAGS/etc,
or have been exported by Soong and are no longer necessary.

Change-Id: I5930d43fda21acc8202b3d8ea010fbefb6ae4cf1
2016-05-25 21:23:20 -07:00
Dan Willemsen
174feb906f Remove (C|CPP|CONLY|LD)FLAGS checked by Soong
At the beginning of every build, Soong has exported its version of these
variables, and has been ensuring that when sorted, the result is the
same. So these variables all have the same flags of the Soong ones, but
may be in different orders. We don't believe any of the remaining order
differences matter. As we remove the Make definitions, the exported
Soong variables will take over.

This only removes lines that change one of these variables:

  [2ND_][CLANG_]HOST_CROSS_GLOBAL_CFLAGS
  [2ND_][CLANG_]HOST_CROSS_GLOBAL_CONLYFLAGS
  [2ND_][CLANG_]HOST_CROSS_GLOBAL_CPPFLAGS
  [2ND_][CLANG_]HOST_CROSS_GLOBAL_LDFLAGS
  [2ND_][CLANG_]HOST_GLOBAL_CFLAGS
  [2ND_][CLANG_]HOST_GLOBAL_CONLYFLAGS
  [2ND_][CLANG_]HOST_GLOBAL_CPPFLAGS
  [2ND_][CLANG_]HOST_GLOBAL_LDFLAGS
  [2ND_][CLANG_]TARGET_GLOBAL_CFLAGS
  [2ND_][CLANG_]TARGET_GLOBAL_CONLYFLAGS
  [2ND_][CLANG_]TARGET_GLOBAL_CPPFLAGS
  [2ND_][CLANG_]TARGET_GLOBAL_LDFLAGS

Many other variables are unnecessary now too, but those will be removed
in another change. For those we can ensure the build.ninja file does not
change, but we expect it to change here due to the ordering differences.

Change-Id: I0bd0778706d02ee27b2784dd8dc6b2c71d37bd3a
2016-05-18 18:10:04 -07:00
Dan Willemsen
8308f506ce Remove (TARGET|HOST)_NO_UNDEFINED_LDFLAGS
We never use it for host modules, and all the target configurations use
the same linker argument. This matches Soong.

Change-Id: Ibcba9a4ce340c7a12306d1fee620a04027c0e292
2016-05-18 12:50:53 -07:00
Dan Willemsen
4863dafcb1 Remove make variables exported from Soong
These have all been strictly checked by Soong, so the values currently
match. Just remove them so that the make variables exported by Soong
will take over.

This also removes some of the GCC reconfiguration, since we haven't
implemented that in Soong. If it becomes useful in the future, we'll
implement it there.

Some things like TARGET_TOOCHAIN_ROOT can nearly be removed, but are
used before the Soong-exported make_vars.mk is loaded. In that case,
added to the clang cflags, so it can be removed once the cflags are
removed.

Others, like LLVM_PREBUILTS_VERSION are loaded even earlier -- in
envsetup.sh before we've even configured Soong. So for now, keep the
Make definition, and continue ensuring it's the same as the Soong
version.

Change-Id: I554b27062ac43610828a8c06d640d919a2dc21ca
2016-05-16 20:39:58 -07:00
Elliott Hughes
505e4ec646 Be smarter about stack-protector on the host.
Some projects are still built with our host GCC 4.8, which doesn't
support -fstack-protector-strong. The combo .mk files are used by
GCC and clang, so it's not safe to turn on -fstack-protector-strong
there. Instead, do it in the clang-specific .mk for now.

We can clean this up when elfutils (the last code built for the host
with GCC that I'm aware of) is built by clang. We'll be able to
remove the host GCC prebuilts too!

Change-Id: I314b9eab071c132a8e2cb8cc779a75ae8abb12e2
2015-12-14 13:20:59 -08:00
Elliott Hughes
ae316d2d59 Enable -fstack-protector-strong for the host.
This results in nearly all functions with the possibility of stack
corruption getting stack canaries, because it applies to any function
taking a reference to the frame or with a local array rather than just
the functions with arrays larger than 8 bytes. It was developed for use
in Chrome (and Chrome OS) and has also been adopted by various other
distributions (Arch, Fedora, Ubuntu, etc).

The code size increase ranges from ~1.5% to ~2.5%, compared to ~0.3% to
~0.7% with the more conservative switch. The increase in the performance
loss is usually minimal. The overall size increase once everything other
than C and C++ code is taken into account is minimal, and it greatly
improves the mitigation of stack buffer overflow vulnerabilities.

https://lwn.net/Articles/584225/

Change-Id: I97a2187cebac64e3b9f22b691d4676b6da083ebd
2015-12-14 11:14:21 -08:00
Dan Willemsen
da9c00da5f Enforce linker version-scripts are valid
Currently, if a version script is passed to the linker (using
-Wl,--version-script,...), it is used to limit symbol visibility and
assign symbol versions. But if a symbol is listed in the version script
but is not present in the binary, no error or warning is given.

Pass -Wl,--no-undefined-version to the linker so that it verifies all
(non-wildcard, C) entries in the version script match symbols in the
binary.

Change-Id: I65878931ab61124ae75e2c738cc733adfb107afc
2015-12-02 19:19:04 -08:00
Shinichiro Hamaji
0e7587a9ea Use .KATI_RESTAT to reduce unnecessary rebuilds of binaries
When a shared object is rebuilt, all dependent libraries and
executables are rebuilt. Such rebuild is unnecessary when there
is no interface change. With this patch, .toc files will be
generated for all .so files. The rule which generates .toc files
has ninja's restat=1 and .toc files are not changed ninja won't
rebuild dependent targets.

Performance:

$ m && touch bionic/libc/stdio/stdio.c && time m
Before: 1m03s (2563 targets)
After: 21s (90 targets)

Bug: 24597504
Change-Id: Ia5dd950273d143f4e99eee8bef7478f1a94cd138
2015-11-04 15:23:59 +09:00
Dan Willemsen
c339398581 Remove trailing / for HOST_TOOLCHAIN_FOR_CLANG
The darwin version doesn't have a trailing slash. The common case is to
append a path to it:

  $(HOST_TOOLCHAIN_FOR_CLANG)/lib/...

Which means we end up with two slashes.

Change-Id: I74e88924ecfd092c5f7871e188ede0aab29cf65b
2015-09-23 23:46:44 +00:00
Elliott Hughes
6f5341259c Merge "Fix Linux host checkbuilds." 2015-08-20 23:56:07 +00:00
Elliott Hughes
ac9eea9463 Fix Linux host checkbuilds.
Turns out that thanks to 9d59f41776 we actually
build *all* the host libraries both 32- and 64-bit. Rather than fix the
libraries (or fixing things so we don't build stuff we don't need) right now,
let's just put _FILE_OFFSET_BITS and _LARGEFILE_SOURCE back.

Change-Id: I6c2d6a6919d1518f775e0d6c050e2c774994c5bd
2015-08-20 16:52:47 -07:00
Elliott Hughes
e31dfe965f Kill host Linux AndroidConfig.h.
We only build 64-bit now anyway.

Change-Id: I4bc9487522d215234509510bee66e4f210d86765
2015-08-20 11:14:23 -07:00
Elliott Hughes
7dd8ec1761 Revert "Revert "Turn on _FORTIFY_SOURCE=2 for the host.""
This reverts commit e27b214fc2.

Change-Id: I3d739c0594dbe4ecd62c5b07064ada7de6cdaadb
2015-05-13 20:15:19 +00:00
Elliott Hughes
e27b214fc2 Revert "Turn on _FORTIFY_SOURCE=2 for the host."
This reverts commit 224806d00e.

Change-Id: I654157ec4be7ff95356ab4a25b27c44762793e74
2015-05-13 19:32:59 +00:00
Elliott Hughes
224806d00e Turn on _FORTIFY_SOURCE=2 for the host.
Bug: http://b/20558757
Change-Id: Ic0c173d25dc6b2fa9c3122a523af5f37bc1b8c55
2015-05-12 21:41:52 -07:00
Nick Kralevich
100acd1001 host compiler: enable compiler hardening flags
Enable the following compiler hardening flags:

* -Wl,-z,relro
* -Wl,-z,now
* -fstack-protector

relro / bind_now make the relro region read-only after linking,
preventing certain attacks against ELF data structures.

stack-protector adds stack canaries, which can detect exploits
which overwrite parts of the stack.

Explicitly not added in this change is FORTIFY_SOURCE=2. Adding that
option turns on glibc's warn_unused_result attributes. This generates
a huge number of new compile time warnings, and for the multiple
makefiles which have -Werror in them, turns those warnings into errors.
I'm not able to fix all the errors right away.

Bug: 20558757
Change-Id: I86791177c6695f5325233d9dd9a5dd3ccc2b1a2f
2015-04-24 21:26:08 -07:00
Dan Albert
343ed674e3 Use prebuilt libclang_rt.profile.
Bug: 17574078
Change-Id: I4838cd5d125a0b2bf76aad2fdaef1ee3122687e8
2015-04-01 19:03:22 -07:00
Chih-Hung Hsieh
3be11c6e61 Upgrade host tool to x86_64-linux-glibc2.15-4.8
BUG: 17915392
Change-Id: I301b8ae70fabedfafea5ae0094bbd46c208f4622
2014-11-06 11:47:08 -08:00
Alexander Ivchenko
ae2d47a47f Remove "-mstackrealign" option from all x86 builds.
For ndk docs change, please refer to:
https://android-review.googlesource.com/#/c/110100/

Change-Id: I8428e7a979eb02441066aeeee43ce693d4d0dc8d
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2014-10-13 19:08:01 +04:00
David 'Digit' Turner
44ee3419e7 Update host linux toolchain to gcc 4.8
This patch ensures the build system uses the prebuilt gcc-4.8 toolchain
when building host Linux binaries, instead of the gcc-4.6 one.

Change-Id: I7b449650714ba4314a780827e0243f2af40ec82c
2014-07-31 19:51:40 +02:00
Ying Wang
5e2ebcbe26 Use hermetic host toolchains.
Change-Id: I6bb72b5728d1075be9645f8473dcf3db759fa66a
2014-07-28 15:14:51 -07:00
Stephen Hines
1b50a12a81 Default to "prescott" as our baseline i686 host build architecture.
Bug: 16408818

Change-Id: I41760605bf9f4589859afd20cc96ccbedb6fe82c
2014-07-18 17:34:43 -07:00
Ying Wang
6feb6d5607 Support host multilib build
This change basically ported our target multilib to the host side.
It supports 2 host build modes: x86 and x86_64 multilib build.
For now you need to set "BUILD_HOST_64bit=true" to switch to x86_64
multilib build. Later we'll default to x86_64 build and have a flag
to force 32-bit only build, which may be needed by SDK build.

In host module definition, like in target ones, you can use the
following
LOCAL variables to set up multilib configuration:
LOCAL_MULTILIB: can be "both", "first", "32" or "64".
It also supports the same set of arch or 32-vs-64 specific LOCAL
variables.
By default, it builds only for the first arch.

To keep path compatibility, in x86_64 build files are still output to
out/host/linux-x86; Both 32-bit and 64-bit executables are in
out/host/linux-86/bin;
In x86_64 build 32-bit shared libraries are installed to
out/host/linux-x86/lib32
and 64-bit shared libraries are installed to out/host/linux-x86/lib;
32-bit object files are output to out/host/linux-x86/obj32 and 64-bit
object files
are output to out/host/linux-x86/obj.

Bug: 13751317
Change-Id: I6044f83b7db369a33e05209e8c588eb6dc83409f
2014-05-14 16:55:04 -07:00
Andrew Hsieh
48f239c94f Disable canonical prefixes of system headers
GCC know a few pre-defined paths (relative to its location) to
search for headers, libraries, program, etc.  By default GCC prefixes
its own path(argv[0]) and calls realpath() which result in absolute
path with all symlink, . and .. removed.

It's usually good to have canonicalised paths, but absolute paths
in *.d file can cause unnecessary relinking when stale entries
in ccache cache hit

Add -no-canonical-prefixes (gcc>=4.6) and
-fno-canonical-system-headers (gcc>4.6) to disable realpath() on
prefixed paths

Change-Id: I58d739e61fb013015fb05a9c98b2132b307f915a
2014-05-09 22:12:49 +08:00
Andrew Hsieh
dfde360b2c Switch to new host prebuilt x86_64-linux-glibc2.11-4.6
Change-Id: I763398d523bf4851a13722f72b12ec69d7a4bb4f
2014-04-23 14:47:00 -07:00
Tim Murray
02cefc93a8 Make Clang host builds hermetic on Linux.
This lays the groundwork for making builds hermetic on Darwin as well.
That will be fixed in a future patch.

bug 13435344

Change-Id: Iae82d0b9efad0598d682ff5fd4daa737aa607866
2014-03-24 19:38:47 -07:00
Andrew Hsieh
cbe162e914 Fix HOST_TOOLCHAIN_PREFIX
Previously HOST_TOOLCHAIN_PREFIX can't accept toolchain in arch-os-*-gcc
format.  Fix it so we can try out new host toolchain, eg.

  HOST_TOOLCHAIN_PREFIX=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux- make

Change-Id: Ic1092593036c41d5471e788654fb4e0991dd7e40
2014-03-12 19:27:59 +08:00
Ian Rogers
aa54033b46 Define __STDC_CONSTANT_MACROS globally to work around host build differences.
Change-Id: I945128b3087b28f62467c7123b759e3514027574
2014-03-10 16:49:41 -07:00
Ian Rogers
c61a9425cd Revert "Define __STDC_LIMIT_MACROS globally to work around host build differences."
This reverts commit 668427c941.

Change-Id: I3694aad84e7499e4c6839db0bd06acf5166e4802
2014-03-10 23:27:01 +00:00
Ian Rogers
668427c941 Define __STDC_LIMIT_MACROS globally to work around host build differences.
Change-Id: I571fc5a4b35c830ca8de4dc3117aef258dffa1bd
2014-03-10 15:30:39 -07:00
Ian Rogers
61e5059ef7 Fix the host inttypes.h problem globally.
Bug: 12708004
Change-Id: I2c75647bac304b82e150c540b9e6c5568997596d
2014-01-29 16:29:11 -08:00
Joshua J. Drake
afb45637b2 Enable NX protections
Add -Wa,--noexecstack and -Wl,-z,noexecstack as default
flags when compiling host-side applications.  This enables
NX protections, which prevent code from executing on the
stack or heap.  NX protections make exploiting memory
corruption issues more challenging and is an important
security feature.

Change-Id: Iae580abe887e01f9029ec2a4e0fc0aae496724a4
2013-12-12 10:47:08 -08:00
Ian Rogers
25ba3b0975 am e2f7bd46: am c148cca6: Merge "Specify -msse3 on host as on target."
* commit 'e2f7bd46fc7b9aa746ae46e551727c4db0356d37':
  Specify -msse3 on host as on target.
2013-02-27 19:03:54 +00:00
Ian Rogers
35a6b4fb65 Specify -msse3 on host as on target.
Make the host and the target x86 build more uniform by using the same machine flags.
Its unlikely Android has ever been built on a machine without SSE3 support.

Bug: 8068608
Change-Id: I19635528b61bf2c6faf02c2e575b1d9bf8025d3a
2013-02-26 15:10:22 -08:00
Ying Wang
79e3f77996 Allow user to override the linux host toolchain.
Bug: 8181840
Change-Id: Ib2a90d33414758e95b1a3c60db62c4188944dfdd
2013-02-12 11:48:37 -08:00
Ying Wang
eb98e08893 am 865d851a: Merge "Remove the obsolete comments and change the misleading var name."
* commit '865d851a8012e13c35d573d98770b7187d32b7f7':
  Remove the obsolete comments and change the misleading var name.
2012-11-12 14:45:59 -08:00
Ying Wang
85e8cda340 Remove the obsolete comments and change the misleading var name.
Change-Id: Ib19099cbce0133f5c7df44fa0fd80215809a1ad8
2012-11-12 14:31:20 -08:00
Ying Wang
5bdf305bbe Move AndroidConfig.h from system/core to the build project.
So unbundled branches don't need to include the system/core project.

Change-Id: Ic4ef62ee6df069b9b2dd123aed95a3e7fcdfc146
2012-09-20 10:33:20 -07:00
Andrew Hsieh
31ef1037bf Added BUILD_HOST_static to build statically linked executable/shared-lib
Statically linked executable/shared-lib (eg. SDK tools) are useful
in sandboxed environment.

In BUILD_HOST_static zipalign needs -lpthread indirectly:
zipalign->libutils.a->liblog.a->logd_write.c->pthread

Change-Id: I615f574e918c83ed1ab82db2453b69d0420cb59c
2012-08-21 14:40:16 +08:00
Ying Wang
da4bf42514 Don't include system/core/include/arch/<arch>/Android.mk for apps-only build.
Bug: 6994483
Change-Id: I76c4d96264cf94a79d59fdeb52bb37c07a9458dd
2012-08-16 16:45:01 -07:00
Andrew Hsieh
f9613a4f73 Added BUILD_HOST_static to build statically linked executable/shared-lib
Statically linked executable/shared-lib (eg. SDK tools) are useful
in sandboxed environment.

In BUILD_HOST_static zipalign needs -lpthread indirectly:
zipalign->libutils.a->liblog.a->logd_write.c->pthread

Change-Id: I8fa91a937b728ccdf942c4ba199efb1e2e49da3d
2012-04-28 00:53:55 +08:00
Jean-Baptiste Queru
4e82d1fa7f On linux, always use the prebuilt host toolchain
Change-Id: I8077c4780e1e3540e5e2133cf0ffa61d474d3acc
2012-04-20 19:04:56 -07:00
Andrew Hsieh
0e63fd37dd Point to new linux prebuilt toolchain for SDK build
Change-Id: I21849119b0f3f45f950e9e6d1da0833aff381fb7
2012-03-13 02:17:35 -07:00
Andrew Hsieh
ed6b815505 BUILD_HOST_64bit=1 to build host tools in 64-bit
By default we build tool in 32-bit.  This flag allow individual tool and its
dependencies to be built in 64-bit (eg. Emulator).  Fixes to resolve 64-bit
porting issues (in other git) will be submitted seperately.

Change-Id: I486cf7ddac727d3c374ed890857d497c3a69e598
2012-02-28 10:24:39 -08:00
Jean-Baptiste Queru
d75dbec617 Revert "Reference new location of SDK toolchain"
This reverts commit 1b834c6660.
2012-01-11 09:00:41 -08:00
Jean-Baptiste Queru
1b834c6660 Reference new location of SDK toolchain
Change-Id: If470d742a92061006d94b72f21df5c642348e179
2012-01-09 15:07:59 -08:00
Jim Huang
cb48497ff2 HOST_linux-x86: Avoid doubly define macro _FORTIFY_SOURCE
While building Android with latest host gcc, it causes the following
build error:

Install: out/host/linux-x86/bin/mkbootimg
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors

In order to make build system happy, this patch does unset macro
_FORTIFY_SOURCE and then define it in host cflags.

Change-Id: Ic37a90f05081a2c3650b3335bc87e9e895900fb2
2011-11-10 13:28:13 -08:00
Jeff Brown
e33ba4c49e Remove the simulator target from all makefiles.
Bug: 5010576

Change-Id: Ie814f4c8d3aa1e7cc7f5735822ab25542f36cf62
2011-07-11 23:51:37 -07:00
David 'Digit' Turner
0960ca7488 Add support for custom Linux host toolchains when building the SDK.
This is needed in order to build Linux SDK binaries that can run
properly on Ubuntu 8.04 (Hardy). By default, the host toolchain
on 10.04 (Lucid) generates machine code that won't run on Hardy
due to GLibc ABI mistmatches.

Note that nothing happens if the new toolchain is not in the
prebuilt tree.

Change-Id: I45c1f68e37e15a0032f885df1c5c0f297b3d8642
2010-12-13 11:52:03 +01:00
Ying Wang
fb644881b6 Disable new longjmp in glibc 2.11 and later.
Bug: 2967937
Change-Id: I4e2a5f806ad45a01ca7f8c4d032cd29fce1d794d
2010-09-01 16:39:11 -07:00