Revert "Merge cpu_features build targets into //system_wrappers."
This reverts commit 2b242d8fba59ccf67e4c5bcf5a1ea80917a23e1c.
Reason for revert: Breaks downstream project.
Original change's description:
> Merge cpu_features build targets into //system_wrappers.
>
> Before this CL, functions declared in cpu_features_wrapper.h where
> not defined in the same build target, causing brittle builds that
> might fail at link time if the binary was not depending on
> //system_wrappers (the target with the definitions), violating [1].
>
> This CL moves everything into //system_wrappers and also moves
> cpu_features_wrapper.h definitions from C to C++ (in order to be able
> to add the definitions to a C++ build target like //system_wrappers).
>
> [1] - https://webrtc.googlesource.com/src/+/refs/heads/master/style-guide.md#h-cc-pairs
>
> Bug: None
> Change-Id: I5a0009cddb17206b19f2a71eeba722faacc4bcae
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183380
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32039}
TBR=mbonadei@webrtc.org,kwiberg@webrtc.org
Change-Id: I4daa7582e55a0343eef72f08ed023c73e0b6456b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: None
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183443
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32040}
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index a03e9ab..8f5ce83 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -54,6 +54,7 @@
"../rtc_base/system:arch",
"../rtc_base/system:file_wrapper",
"../system_wrappers",
+ "../system_wrappers:cpu_features_api",
"third_party/ooura:fft_size_256",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
@@ -184,6 +185,7 @@
"../rtc_base:sanitizer",
"../rtc_base/system:arch",
"../system_wrappers",
+ "../system_wrappers:cpu_features_api",
"third_party/ooura:fft_size_256",
"third_party/spl_sqrt_floor",
]
@@ -230,7 +232,7 @@
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
"../rtc_base/system:arch",
- "../system_wrappers",
+ "../system_wrappers:cpu_features_api",
]
if (current_cpu == "x86" || current_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
@@ -381,7 +383,7 @@
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base/system:arch",
- "../system_wrappers",
+ "../system_wrappers:cpu_features_api",
"../test:fileutils",
"../test:rtc_expect_death",
"../test:test_main",
diff --git a/common_audio/third_party/ooura/BUILD.gn b/common_audio/third_party/ooura/BUILD.gn
index 0cdf98e..742f620 100644
--- a/common_audio/third_party/ooura/BUILD.gn
+++ b/common_audio/third_party/ooura/BUILD.gn
@@ -16,7 +16,7 @@
]
deps = [
"../../../rtc_base/system:arch",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
]
cflags = []
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 5579539..be97051 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -609,7 +609,7 @@
"../../rtc_base:compile_assert_c",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:sanitizer",
- "../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"../third_party/fft",
]
@@ -2067,6 +2067,7 @@
"../../rtc_base/synchronization:mutex",
"../../rtc_base/system:arch",
"../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"../../test:audio_codec_mocks",
"../../test:field_trial",
"../../test:fileutils",
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 83fdcef..1510930 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -189,7 +189,7 @@
"../../rtc_base:sanitizer",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/system:rtc_export",
- "../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"../../system_wrappers:field_trial",
"../../system_wrappers:metrics",
"aec3",
@@ -375,6 +375,7 @@
"../../rtc_base/system:arch",
"../../rtc_base/system:file_wrapper",
"../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"../../test:fileutils",
"../../test:rtc_expect_death",
"../../test:test_support",
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index 6816d73..c312b0e 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -142,7 +142,7 @@
"../../../rtc_base:safe_minmax",
"../../../rtc_base/experiments:field_trial_parser",
"../../../rtc_base/system:arch",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
"../../../system_wrappers:field_trial",
"../../../system_wrappers:metrics",
"../utility:cascaded_biquad_filter",
@@ -308,7 +308,7 @@
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:safe_minmax",
"../../../rtc_base/system:arch",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
"../../../test:field_trial",
"../../../test:test_support",
"../utility:cascaded_biquad_filter",
diff --git a/modules/audio_processing/aecm/BUILD.gn b/modules/audio_processing/aecm/BUILD.gn
index 61e9aff..6f1c331 100644
--- a/modules/audio_processing/aecm/BUILD.gn
+++ b/modules/audio_processing/aecm/BUILD.gn
@@ -21,7 +21,7 @@
"../../../rtc_base:checks",
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:sanitizer",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
"../utility:legacy_delay_estimator",
]
cflags = []
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index e5b3980..9ed6399 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -78,7 +78,7 @@
"../../../common_audio/third_party/ooura:fft_size_256",
"../../../rtc_base:checks",
"../../../rtc_base:rtc_base_approved",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
]
if (rtc_build_with_neon) {
diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn
index ca2db97..bfef225 100644
--- a/modules/audio_processing/agc2/BUILD.gn
+++ b/modules/audio_processing/agc2/BUILD.gn
@@ -153,7 +153,7 @@
"../../../common_audio/third_party/ooura:fft_size_128",
"../../../rtc_base:checks",
"../../../rtc_base:macromagic",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
]
configs += [ "..:apm_debug_dump" ]
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 3bdfdbc..99b4e82 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -48,7 +48,7 @@
"../../../../rtc_base:checks",
"../../../../rtc_base:rtc_base_approved",
"../../../../rtc_base/system:arch",
- "../../../../system_wrappers",
+ "../../../../system_wrappers:cpu_features_api",
"../../utility:pffft_wrapper",
"//third_party/rnnoise:rnn_vad",
]
@@ -67,7 +67,7 @@
"../../../../api:scoped_refptr",
"../../../../rtc_base:checks",
"../../../../rtc_base/system:arch",
- "../../../../system_wrappers",
+ "../../../../system_wrappers:cpu_features_api",
"../../../../test:fileutils",
"../../../../test:test_support",
]
diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn
index f0842c5..7197705 100644
--- a/modules/audio_processing/ns/BUILD.gn
+++ b/modules/audio_processing/ns/BUILD.gn
@@ -60,7 +60,7 @@
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:safe_minmax",
"../../../rtc_base/system:arch",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
"../../../system_wrappers:field_trial",
"../../../system_wrappers:metrics",
"../utility:cascaded_biquad_filter",
@@ -87,7 +87,7 @@
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:safe_minmax",
"../../../rtc_base/system:arch",
- "../../../system_wrappers",
+ "../../../system_wrappers:cpu_features_api",
"../../../test:test_support",
"../utility:cascaded_biquad_filter",
]
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 1cba946..b40b743 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -115,7 +115,7 @@
":primitives",
"../../rtc_base:checks",
"../../rtc_base:rtc_base_approved",
- "../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"../../test:test_support",
]
if (rtc_desktop_capture_supported) {
@@ -486,6 +486,7 @@
"../../rtc_base/system:arch",
"../../rtc_base/system:rtc_export",
"../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"../../system_wrappers:metrics",
]
absl_deps = [
diff --git a/modules/video_processing/BUILD.gn b/modules/video_processing/BUILD.gn
index abc9f03..4354454 100644
--- a/modules/video_processing/BUILD.gn
+++ b/modules/video_processing/BUILD.gn
@@ -37,7 +37,7 @@
"../../rtc_base:checks",
"../../rtc_base:rtc_base_approved",
"../../rtc_base/system:arch",
- "../../system_wrappers",
+ "../../system_wrappers:cpu_features_api",
"//third_party/libyuv",
]
if (build_video_processing_sse2) {
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index 97c09f5..2d50111 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -16,7 +16,6 @@
visibility = [ "*" ]
sources = [
"include/clock.h",
- "include/cpu_features_wrapper.h",
"include/cpu_info.h",
"include/ntp_time.h",
"include/rtp_to_ntp_estimator.h",
@@ -31,6 +30,7 @@
defines = []
libs = []
deps = [
+ ":cpu_features_api",
"../api:array_view",
"../api/units:timestamp",
"../modules:module_api_public",
@@ -50,8 +50,7 @@
"/nsprpub/pr/include",
]
} else {
- sources += [ "source/cpu_features_android.cc" ]
- deps += [ "//third_party/android_sdk:cpu_features" ]
+ deps += [ ":cpu_features_android" ]
}
libs += [ "log" ]
@@ -59,7 +58,7 @@
if (is_linux) {
if (!build_with_chromium) {
- sources += [ "source/cpu_features_linux.cc" ]
+ deps += [ ":cpu_features_linux" ]
}
libs += [ "rt" ]
@@ -79,6 +78,10 @@
]
}
+rtc_source_set("cpu_features_api") {
+ sources = [ "include/cpu_features_wrapper.h" ]
+}
+
rtc_library("field_trial") {
visibility = [ "*" ]
public = [ "include/field_trial.h" ]
@@ -108,6 +111,24 @@
]
}
+if (is_android && !build_with_mozilla) {
+ rtc_library("cpu_features_android") {
+ sources = [ "source/cpu_features_android.c" ]
+
+ deps = [ "//third_party/android_sdk:cpu_features" ]
+ }
+}
+
+if (is_linux) {
+ rtc_library("cpu_features_linux") {
+ sources = [ "source/cpu_features_linux.c" ]
+ deps = [
+ ":cpu_features_api",
+ "../rtc_base/system:arch",
+ ]
+ }
+}
+
if (rtc_include_tests) {
rtc_test("system_wrappers_unittests") {
testonly = true
diff --git a/system_wrappers/include/cpu_features_wrapper.h b/system_wrappers/include/cpu_features_wrapper.h
index f4b3fed..02d54b4 100644
--- a/system_wrappers/include/cpu_features_wrapper.h
+++ b/system_wrappers/include/cpu_features_wrapper.h
@@ -13,6 +13,10 @@
#include <stdint.h>
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
// List of features in x86.
typedef enum { kSSE2, kSSE3, kAVX2 } CPUFeature;
@@ -37,4 +41,8 @@
// values in the above enum definition as a bitmask.
extern uint64_t WebRtc_GetCPUFeaturesARM(void);
+#if defined(__cplusplus) || defined(c_plusplus)
+} // extern "C"
+#endif
+
#endif // SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_
diff --git a/system_wrappers/source/cpu_features_android.cc b/system_wrappers/source/cpu_features_android.c
similarity index 100%
rename from system_wrappers/source/cpu_features_android.cc
rename to system_wrappers/source/cpu_features_android.c
diff --git a/system_wrappers/source/cpu_features_linux.cc b/system_wrappers/source/cpu_features_linux.c
similarity index 98%
rename from system_wrappers/source/cpu_features_linux.cc
rename to system_wrappers/source/cpu_features_linux.c
index 05ff9b3..37739c1 100644
--- a/system_wrappers/source/cpu_features_linux.cc
+++ b/system_wrappers/source/cpu_features_linux.c
@@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <features.h>
#include <stdlib.h>
#include <string.h>
+#include <features.h>
#ifdef __GLIBC_PREREQ
#define WEBRTC_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
@@ -21,10 +21,10 @@
#if WEBRTC_GLIBC_PREREQ(2, 16)
#include <sys/auxv.h>
#else
-#include <errno.h>
#include <fcntl.h>
-#include <link.h>
#include <unistd.h>
+#include <errno.h>
+#include <link.h>
#endif
#include "rtc_base/system/arch.h"
@@ -36,7 +36,7 @@
uint64_t WebRtc_GetCPUFeaturesARM(void) {
uint64_t result = 0;
int architecture = 0;
- uint64_t hwcap = 0;
+ unsigned long hwcap = 0;
const char* platform = NULL;
#if WEBRTC_GLIBC_PREREQ(2, 16)
hwcap = getauxval(AT_HWCAP);