From b9c828ea838d0104e72ce1bca090d8dab3183a18 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Wed, 8 Jul 2020 00:00:18 -0400 Subject: [PATCH] =?UTF-8?q?android:=20Fix=20=E2=80=9Cgn=20analyze=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Android, the compat library built compat/android/sys/mman.cc, which provides a fallback for mmap, and compat/linux/sys/mman.cc, which provides a fallback for memfd_create. This can result in two object files colliding in the library, which is flagged as a “gn analyze” error: > ERROR at //crashpad/compat/BUILD.gn:62:5: Duplicate object file > static_library(target_name) { > ^---------------------------- > The target //crashpad/compat:compat > generates two object files with the same name: > obj/crashpad/compat/compat/mman.o > > It could be you accidentally have a file listed twice in the > sources. Or, depending on how your toolchain maps sources to > object files, two source files with the same name in different > directories could map to the same object file. > > In the latter case, either rename one of the files or move one of > the sources to a separate source_set to avoid them both being in > the same target. The files are renamed to avoid this collision. The associated headers cannot be renamed because they need to shadow the SDK’s copies. There is no “gn analyze” conflict reported for headers with the same name. Change-Id: Ia49ef5ff8375673395597e96555f72f7c69e3564 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2285965 Commit-Queue: Mark Mentovai Reviewed-by: Robert Sesek --- compat/BUILD.gn | 4 ++-- compat/android/sys/{mman.cc => mman_mmap.cc} | 0 compat/compat.gyp | 2 +- compat/linux/sys/{mman.cc => mman_memfd_create.cc} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename compat/android/sys/{mman.cc => mman_mmap.cc} (100%) rename compat/linux/sys/{mman.cc => mman_memfd_create.cc} (100%) diff --git a/compat/BUILD.gn b/compat/BUILD.gn index ba9d78cd..f2ffcf5f 100644 --- a/compat/BUILD.gn +++ b/compat/BUILD.gn @@ -99,8 +99,8 @@ compat_target("compat") { if (crashpad_is_linux || crashpad_is_android) { sources += [ "linux/signal.h", - "linux/sys/mman.cc", "linux/sys/mman.h", + "linux/sys/mman_memfd_create.cc", "linux/sys/ptrace.h", "linux/sys/user.h", ] @@ -119,8 +119,8 @@ compat_target("compat") { "android/sched.h", "android/sys/epoll.cc", "android/sys/epoll.h", - "android/sys/mman.cc", "android/sys/mman.h", + "android/sys/mman_mmap.cc", "android/sys/syscall.h", "android/sys/user.h", ] diff --git a/compat/android/sys/mman.cc b/compat/android/sys/mman_mmap.cc similarity index 100% rename from compat/android/sys/mman.cc rename to compat/android/sys/mman_mmap.cc diff --git a/compat/compat.gyp b/compat/compat.gyp index 6294d1fc..b99d6905 100644 --- a/compat/compat.gyp +++ b/compat/compat.gyp @@ -31,8 +31,8 @@ 'android/sched.h', 'android/sys/epoll.cc', 'android/sys/epoll.h', - 'android/sys/mman.cc', 'android/sys/mman.h', + 'android/sys/mman_mmap.cc', 'android/sys/syscall.h', 'android/sys/user.h', 'linux/signal.h', diff --git a/compat/linux/sys/mman.cc b/compat/linux/sys/mman_memfd_create.cc similarity index 100% rename from compat/linux/sys/mman.cc rename to compat/linux/sys/mman_memfd_create.cc