Merge "Don't pass -lrt or -lgcc_s to darwin rust compiles" into main am: ff4d5b40ca

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2771124

Change-Id: I9728cca90fca6477f7f8a5be3a083a44ab7b539f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Colin Cross 2023-10-04 17:00:50 +00:00 committed by Automerger Merge Worker
commit 57a30b28df

View file

@ -327,9 +327,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.LinkFlags = append(flags.LinkFlags, cc.RpathFlags(ctx)...)
}
if !ctx.toolchain().Bionic() && ctx.Os() != android.LinuxMusl && !ctx.Windows() {
// Add -lc, -lrt, -ldl, -lpthread, -lm, -lrt and -lgcc_s to host builds to match the default behavior of device
// builds. This is irrelevant for the Windows target as these are Posix specific.
if ctx.Os() == android.Linux {
// Add -lc, -lrt, -ldl, -lpthread, -lm and -lgcc_s to glibc builds to match
// the default behavior of device builds.
flags.LinkFlags = append(flags.LinkFlags,
"-lc",
"-lrt",
@ -338,6 +338,15 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
"-lm",
"-lgcc_s",
)
} else if ctx.Os() == android.Darwin {
// Add -lc, -ldl, -lpthread and -lm to glibc darwin builds to match the default
// behavior of device builds.
flags.LinkFlags = append(flags.LinkFlags,
"-lc",
"-ldl",
"-lpthread",
"-lm",
)
}
return flags
}