Use source_sets in component builds and static_library in release builds.

Static libraries don't guarantee that an exported symbol gets linked
into a shared library (and in order to support Chromium's component
build mode, WebRTC needs to be linked as a shared library).

Source sets always pass all the object files to the linker.

On the flip side, source_sets link more object files in release builds
and to avoid this, this CL introduces a the GN template "rtc_library" that
expands to static_library during release builds and to source_set during
component builds.

See: https://gn.googlesource.com/gn/+/master/docs/reference.md#func_source_set

Bug: webrtc:9419
Change-Id: I4667e820c2b3fcec417becbd2034acc13e4f04fe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157168
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#29525}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index a472b3d..ab99e73 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -39,7 +39,7 @@
 }
 
 if (!build_with_chromium) {
-  rtc_source_set("create_peerconnection_factory") {
+  rtc_library("create_peerconnection_factory") {
     visibility = [ "*" ]
     allow_poison = [ "default_task_queue" ]
     sources = [
@@ -66,7 +66,7 @@
   }
 }
 
-rtc_source_set("rtp_headers") {
+rtc_library("rtp_headers") {
   visibility = [ "*" ]
   sources = [
     "rtp_headers.cc",
@@ -81,7 +81,7 @@
   ]
 }
 
-rtc_source_set("rtp_packet_info") {
+rtc_library("rtp_packet_info") {
   visibility = [ "*" ]
   sources = [
     "rtp_packet_info.cc",
@@ -100,7 +100,7 @@
   ]
 }
 
-rtc_source_set("media_stream_interface") {
+rtc_library("media_stream_interface") {
   visibility = [ "*" ]
   sources = [
     "media_stream_interface.cc",
@@ -120,7 +120,7 @@
   ]
 }
 
-rtc_static_library("libjingle_peerconnection_api") {
+rtc_library("libjingle_peerconnection_api") {
   visibility = [ "*" ]
   cflags = []
   sources = [
@@ -215,7 +215,7 @@
   ]
 }
 
-rtc_source_set("rtc_error") {
+rtc_library("rtc_error") {
   visibility = [ "*" ]
   sources = [
     "rtc_error.cc",
@@ -295,7 +295,7 @@
   ]
 }
 
-rtc_source_set("rtp_parameters") {
+rtc_library("rtp_parameters") {
   visibility = [ "*" ]
   sources = [
     "media_types.cc",
@@ -370,7 +370,7 @@
   ]
 }
 
-rtc_source_set("test_dependency_factory") {
+rtc_library("test_dependency_factory") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -385,7 +385,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("create_video_quality_test_fixture_api") {
+  rtc_library("create_video_quality_test_fixture_api") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -401,7 +401,7 @@
     ]
   }
 
-  rtc_source_set("create_network_emulation_manager") {
+  rtc_library("create_network_emulation_manager") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -414,7 +414,7 @@
     ]
   }
 
-  rtc_source_set("create_peerconnection_quality_test_fixture") {
+  rtc_library("create_peerconnection_quality_test_fixture") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -438,7 +438,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_log_output_file") {
+rtc_library("rtc_event_log_output_file") {
   visibility = [ "*" ]
   sources = [
     "rtc_event_log_output_file.cc",
@@ -472,7 +472,7 @@
   ]
 }
 
-rtc_source_set("audio_options_api") {
+rtc_library("audio_options_api") {
   visibility = [ "*" ]
   sources = [
     "audio_options.cc",
@@ -486,7 +486,7 @@
   ]
 }
 
-rtc_source_set("transport_api") {
+rtc_library("transport_api") {
   visibility = [ "*" ]
   sources = [
     "call/transport.cc",
@@ -572,7 +572,7 @@
   ]
 }
 
-rtc_source_set("ice_transport_factory") {
+rtc_library("ice_transport_factory") {
   visibility = [ "*" ]
   sources = [
     "ice_transport_factory.cc",
@@ -589,7 +589,7 @@
   ]
 }
 
-rtc_source_set("neteq_simulator_api") {
+rtc_library("neteq_simulator_api") {
   visibility = [ "*" ]
   sources = [
     "test/neteq_simulator.cc",
@@ -609,7 +609,7 @@
 
 if (rtc_include_tests) {
   if (rtc_enable_protobuf) {
-    rtc_source_set("audioproc_f_api") {
+    rtc_library("audioproc_f_api") {
       visibility = [ "*" ]
       testonly = true
       sources = [
@@ -624,7 +624,7 @@
       ]
     }
 
-    rtc_source_set("neteq_simulator_factory") {
+    rtc_library("neteq_simulator_factory") {
       visibility = [ "*" ]
       testonly = true
       sources = [
@@ -650,7 +650,7 @@
     ]
   }
 
-  rtc_source_set("create_simulcast_test_fixture_api") {
+  rtc_library("create_simulcast_test_fixture_api") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -665,7 +665,7 @@
     ]
   }
 
-  rtc_source_set("videocodec_test_fixture_api") {
+  rtc_library("videocodec_test_fixture_api") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -682,7 +682,7 @@
     ]
   }
 
-  rtc_source_set("create_videocodec_test_fixture_api") {
+  rtc_library("create_videocodec_test_fixture_api") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -721,7 +721,7 @@
     ]
   }
 
-  rtc_source_set("mock_frame_encryptor") {
+  rtc_library("mock_frame_encryptor") {
     testonly = true
     sources = [
       "test/mock_frame_encryptor.cc",
@@ -735,7 +735,7 @@
     ]
   }
 
-  rtc_source_set("mock_frame_decryptor") {
+  rtc_library("mock_frame_decryptor") {
     testonly = true
     sources = [
       "test/mock_frame_decryptor.cc",
@@ -748,7 +748,7 @@
     ]
   }
 
-  rtc_source_set("fake_frame_encryptor") {
+  rtc_library("fake_frame_encryptor") {
     testonly = true
     sources = [
       "test/fake_frame_encryptor.cc",
@@ -765,7 +765,7 @@
     ]
   }
 
-  rtc_source_set("fake_frame_decryptor") {
+  rtc_library("fake_frame_decryptor") {
     testonly = true
     sources = [
       "test/fake_frame_decryptor.cc",
@@ -859,7 +859,7 @@
     ]
   }
 
-  rtc_source_set("mock_video_decoder") {
+  rtc_library("mock_video_decoder") {
     visibility = [ "*" ]
 
     testonly = true
@@ -874,7 +874,7 @@
     ]
   }
 
-  rtc_source_set("mock_video_encoder") {
+  rtc_library("mock_video_encoder") {
     visibility = [ "*" ]
 
     testonly = true
@@ -905,7 +905,7 @@
     ]
   }
 
-  rtc_source_set("loopback_media_transport") {
+  rtc_library("loopback_media_transport") {
     testonly = true
 
     sources = [
@@ -922,7 +922,7 @@
     ]
   }
 
-  rtc_source_set("rtc_api_unittests") {
+  rtc_library("rtc_api_unittests") {
     testonly = true
 
     sources = [
@@ -956,7 +956,7 @@
     ]
   }
 
-  rtc_source_set("compile_all_headers") {
+  rtc_library("compile_all_headers") {
     testonly = true
 
     sources = [
diff --git a/api/audio/BUILD.gn b/api/audio/BUILD.gn
index ffc47a9..bc68190 100644
--- a/api/audio/BUILD.gn
+++ b/api/audio/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("audio_frame_api") {
+rtc_library("audio_frame_api") {
   visibility = [ "*" ]
   sources = [
     "audio_frame.cc",
@@ -36,7 +36,7 @@
   ]
 }
 
-rtc_source_set("aec3_config") {
+rtc_library("aec3_config") {
   visibility = [ "*" ]
   sources = [
     "echo_canceller3_config.cc",
@@ -50,7 +50,7 @@
   ]
 }
 
-rtc_source_set("aec3_config_json") {
+rtc_library("aec3_config_json") {
   visibility = [ "*" ]
   sources = [
     "echo_canceller3_config_json.cc",
@@ -66,7 +66,7 @@
   ]
 }
 
-rtc_source_set("aec3_factory") {
+rtc_library("aec3_factory") {
   visibility = [ "*" ]
   configs += [ "../../modules/audio_processing:apm_debug_dump" ]
   sources = [
diff --git a/api/audio/test/BUILD.gn b/api/audio/test/BUILD.gn
index 4e04a8a..d62baf1 100644
--- a/api/audio/test/BUILD.gn
+++ b/api/audio/test/BUILD.gn
@@ -13,7 +13,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("audio_api_unittests") {
+  rtc_library("audio_api_unittests") {
     testonly = true
     sources = [
       "audio_frame_unittest.cc",
diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn
index 65da28f..18126d8 100644
--- a/api/audio_codecs/BUILD.gn
+++ b/api/audio_codecs/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_source_set("audio_codecs_api") {
+rtc_library("audio_codecs_api") {
   visibility = [ "*" ]
   sources = [
     "audio_codec_pair_id.cc",
@@ -43,7 +43,7 @@
   ]
 }
 
-rtc_static_library("builtin_audio_decoder_factory") {
+rtc_library("builtin_audio_decoder_factory") {
   visibility = [ "*" ]
   allow_poison = [ "audio_codecs" ]
   sources = [
@@ -77,7 +77,7 @@
   }
 }
 
-rtc_static_library("builtin_audio_encoder_factory") {
+rtc_library("builtin_audio_encoder_factory") {
   visibility = [ "*" ]
   allow_poison = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/L16/BUILD.gn b/api/audio_codecs/L16/BUILD.gn
index dff62a0..bef6712 100644
--- a/api/audio_codecs/L16/BUILD.gn
+++ b/api/audio_codecs/L16/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_static_library("audio_encoder_L16") {
+rtc_library("audio_encoder_L16") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -30,7 +30,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_L16") {
+rtc_library("audio_decoder_L16") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn
index ebcc249..ba0586b 100644
--- a/api/audio_codecs/g711/BUILD.gn
+++ b/api/audio_codecs/g711/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_static_library("audio_encoder_g711") {
+rtc_library("audio_encoder_g711") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -30,7 +30,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_g711") {
+rtc_library("audio_decoder_g711") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/g722/BUILD.gn b/api/audio_codecs/g722/BUILD.gn
index ccb4801..952188a 100644
--- a/api/audio_codecs/g722/BUILD.gn
+++ b/api/audio_codecs/g722/BUILD.gn
@@ -19,7 +19,7 @@
   ]
 }
 
-rtc_static_library("audio_encoder_g722") {
+rtc_library("audio_encoder_g722") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -38,7 +38,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_g722") {
+rtc_library("audio_decoder_g722") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn
index 559ae2b..14f9268 100644
--- a/api/audio_codecs/ilbc/BUILD.gn
+++ b/api/audio_codecs/ilbc/BUILD.gn
@@ -19,7 +19,7 @@
   ]
 }
 
-rtc_static_library("audio_encoder_ilbc") {
+rtc_library("audio_encoder_ilbc") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -37,7 +37,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_ilbc") {
+rtc_library("audio_decoder_ilbc") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/isac/BUILD.gn b/api/audio_codecs/isac/BUILD.gn
index d558d20..719aee6 100644
--- a/api/audio_codecs/isac/BUILD.gn
+++ b/api/audio_codecs/isac/BUILD.gn
@@ -68,7 +68,7 @@
   }
 }
 
-rtc_static_library("audio_encoder_isac_fix") {
+rtc_library("audio_encoder_isac_fix") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -84,7 +84,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_isac_fix") {
+rtc_library("audio_decoder_isac_fix") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -100,7 +100,7 @@
   ]
 }
 
-rtc_static_library("audio_encoder_isac_float") {
+rtc_library("audio_encoder_isac_float") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -117,7 +117,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_isac_float") {
+rtc_library("audio_decoder_isac_float") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn
index 35c3cbf..7131b28 100644
--- a/api/audio_codecs/opus/BUILD.gn
+++ b/api/audio_codecs/opus/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_static_library("audio_encoder_opus_config") {
+rtc_library("audio_encoder_opus_config") {
   visibility = [ "*" ]
   sources = [
     "audio_encoder_multi_channel_opus_config.cc",
@@ -40,7 +40,7 @@
   ]
 }
 
-rtc_source_set("audio_encoder_opus") {
+rtc_library("audio_encoder_opus") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   public = [
@@ -60,7 +60,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_opus") {
+rtc_library("audio_decoder_opus") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -77,7 +77,7 @@
   ]
 }
 
-rtc_source_set("audio_encoder_multiopus") {
+rtc_library("audio_encoder_multiopus") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   public = [
@@ -96,7 +96,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_multiopus") {
+rtc_library("audio_decoder_multiopus") {
   visibility = [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
diff --git a/api/audio_codecs/test/BUILD.gn b/api/audio_codecs/test/BUILD.gn
index 61234f5..575f062 100644
--- a/api/audio_codecs/test/BUILD.gn
+++ b/api/audio_codecs/test/BUILD.gn
@@ -13,7 +13,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("audio_codecs_api_unittests") {
+  rtc_library("audio_codecs_api_unittests") {
     testonly = true
     sources = [
       "audio_decoder_factory_template_unittest.cc",
diff --git a/api/crypto/BUILD.gn b/api/crypto/BUILD.gn
index 685dccd..302b16e 100644
--- a/api/crypto/BUILD.gn
+++ b/api/crypto/BUILD.gn
@@ -16,7 +16,7 @@
   ]
 }
 
-rtc_source_set("options") {
+rtc_library("options") {
   visibility = [ "*" ]
   sources = [
     "crypto_options.cc",
diff --git a/api/rtc_event_log/BUILD.gn b/api/rtc_event_log/BUILD.gn
index bd2570b..ef7ea2c 100644
--- a/api/rtc_event_log/BUILD.gn
+++ b/api/rtc_event_log/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("rtc_event_log") {
+rtc_library("rtc_event_log") {
   visibility = [ "*" ]
   sources = [
     "rtc_event.cc",
@@ -26,7 +26,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_log_factory") {
+rtc_library("rtc_event_log_factory") {
   visibility = [ "*" ]
   sources = [
     "rtc_event_log_factory.cc",
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index 4b84607..d3e7b24 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("task_queue") {
+rtc_library("task_queue") {
   visibility = [ "*" ]
   public = [
     "queued_task.h",
@@ -28,7 +28,7 @@
   ]
 }
 
-rtc_source_set("task_queue_test") {
+rtc_library("task_queue_test") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -47,7 +47,7 @@
   ]
 }
 
-rtc_source_set("default_task_queue_factory") {
+rtc_library("default_task_queue_factory") {
   visibility = [ "*" ]
   if (!is_ios && !is_android) {
     poisonous = [ "default_task_queue" ]
@@ -75,7 +75,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("task_queue_default_factory_unittests") {
+  rtc_library("task_queue_default_factory_unittests") {
     testonly = true
     sources = [
       "default_task_queue_factory_unittest.cc",
diff --git a/api/test/video/BUILD.gn b/api/test/video/BUILD.gn
index a4a0d7b..4ebb0c9 100644
--- a/api/test/video/BUILD.gn
+++ b/api/test/video/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("function_video_factory") {
+rtc_library("function_video_factory") {
   visibility = [ "*" ]
   testonly = true
   public = [
diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn
index 3c11a1a..cd8c01b 100644
--- a/api/transport/BUILD.gn
+++ b/api/transport/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("bitrate_settings") {
+rtc_library("bitrate_settings") {
   visibility = [ "*" ]
   sources = [
     "bitrate_settings.cc",
@@ -27,7 +27,7 @@
   ]
 }
 
-rtc_static_library("network_control") {
+rtc_library("network_control") {
   visibility = [ "*" ]
   sources = [
     "network_control.h",
@@ -57,7 +57,7 @@
   ]
 }
 
-rtc_source_set("field_trial_based_config") {
+rtc_library("field_trial_based_config") {
   visibility = [ "*" ]
   sources = [
     "field_trial_based_config.cc",
@@ -88,7 +88,7 @@
   ]
 }
 
-rtc_static_library("goog_cc") {
+rtc_library("goog_cc") {
   visibility = [ "*" ]
   sources = [
     "goog_cc_factory.cc",
@@ -114,7 +114,7 @@
       "..:simulated_network_api",
     ]
   }
-  rtc_source_set("test_feedback_generator") {
+  rtc_library("test_feedback_generator") {
     testonly = true
     sources = [
       "test/create_feedback_generator.cc",
diff --git a/api/transport/media/BUILD.gn b/api/transport/media/BUILD.gn
index fe8e4e4..ca7531d 100644
--- a/api/transport/media/BUILD.gn
+++ b/api/transport/media/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("media_transport_interface") {
+rtc_library("media_transport_interface") {
   visibility = [ "*" ]
   sources = [
     "media_transport_config.cc",
@@ -33,7 +33,7 @@
   ]
 }
 
-rtc_source_set("audio_interfaces") {
+rtc_library("audio_interfaces") {
   visibility = [ "*" ]
   sources = [
     "audio_transport.cc",
@@ -44,7 +44,7 @@
   ]
 }
 
-rtc_source_set("video_interfaces") {
+rtc_library("video_interfaces") {
   visibility = [ "*" ]
   sources = [
     "video_transport.cc",
diff --git a/api/units/BUILD.gn b/api/units/BUILD.gn
index 1f72579..45cdcd3 100644
--- a/api/units/BUILD.gn
+++ b/api/units/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("data_rate") {
+rtc_library("data_rate") {
   visibility = [ "*" ]
   sources = [
     "data_rate.cc",
@@ -26,7 +26,7 @@
   ]
 }
 
-rtc_source_set("data_size") {
+rtc_library("data_size") {
   visibility = [ "*" ]
   sources = [
     "data_size.cc",
@@ -41,7 +41,7 @@
   ]
 }
 
-rtc_source_set("time_delta") {
+rtc_library("time_delta") {
   visibility = [ "*" ]
   sources = [
     "time_delta.cc",
@@ -56,7 +56,7 @@
   ]
 }
 
-rtc_source_set("frequency") {
+rtc_library("frequency") {
   visibility = [ "*" ]
   sources = [
     "frequency.cc",
@@ -72,7 +72,7 @@
   ]
 }
 
-rtc_source_set("timestamp") {
+rtc_library("timestamp") {
   visibility = [ "*" ]
   sources = [
     "timestamp.cc",
@@ -89,7 +89,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("units_unittests") {
+  rtc_library("units_unittests") {
     testonly = true
     sources = [
       "data_rate_unittest.cc",
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index eda6d47..1473229 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("video_rtp_headers") {
+rtc_library("video_rtp_headers") {
   visibility = [ "*" ]
   sources = [
     "color_space.cc",
@@ -31,7 +31,7 @@
   ]
 }
 
-rtc_source_set("video_frame") {
+rtc_library("video_frame") {
   visibility = [ "*" ]
   sources = [
     "video_codec_type.h",
@@ -63,7 +63,7 @@
   ]
 }
 
-rtc_source_set("video_frame_i420") {
+rtc_library("video_frame_i420") {
   visibility = [ "*" ]
   sources = [
     "i420_buffer.cc",
@@ -81,7 +81,7 @@
   ]
 }
 
-rtc_source_set("video_frame_i010") {
+rtc_library("video_frame_i010") {
   visibility = [ "*" ]
   sources = [
     "i010_buffer.cc",
@@ -99,7 +99,7 @@
   ]
 }
 
-rtc_source_set("encoded_image") {
+rtc_library("encoded_image") {
   visibility = [ "*" ]
   sources = [
     "encoded_image.cc",
@@ -122,7 +122,7 @@
   ]
 }
 
-rtc_source_set("encoded_frame") {
+rtc_library("encoded_frame") {
   visibility = [ "*" ]
   sources = [
     "encoded_frame.cc",
@@ -142,7 +142,7 @@
   deps = []
 }
 
-rtc_source_set("video_bitrate_allocation") {
+rtc_library("video_bitrate_allocation") {
   visibility = [ "*" ]
   sources = [
     "video_bitrate_allocation.cc",
@@ -158,7 +158,7 @@
   ]
 }
 
-rtc_source_set("video_bitrate_allocator") {
+rtc_library("video_bitrate_allocator") {
   visibility = [ "*" ]
   sources = [
     "video_bitrate_allocator.cc",
@@ -198,7 +198,7 @@
   ]
 }
 
-rtc_source_set("video_stream_decoder_create") {
+rtc_library("video_stream_decoder_create") {
   visibility = [ "*" ]
   sources = [
     "video_stream_decoder_create.cc",
@@ -214,7 +214,7 @@
   ]
 }
 
-rtc_source_set("video_stream_encoder") {
+rtc_library("video_stream_encoder") {
   visibility = [ "*" ]
   sources = [
     "video_stream_encoder_interface.h",
@@ -238,7 +238,7 @@
   ]
 }
 
-rtc_source_set("video_stream_encoder_create") {
+rtc_library("video_stream_encoder_create") {
   visibility = [ "*" ]
   sources = [
     "video_stream_encoder_create.cc",
@@ -255,7 +255,7 @@
   ]
 }
 
-rtc_static_library("builtin_video_bitrate_allocator_factory") {
+rtc_library("builtin_video_bitrate_allocator_factory") {
   visibility = [ "*" ]
   sources = [
     "builtin_video_bitrate_allocator_factory.cc",
@@ -277,7 +277,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("video_unittests") {
+  rtc_library("video_unittests") {
     testonly = true
     sources = [
       "video_stream_decoder_create_unittest.cc",
diff --git a/api/video/test/BUILD.gn b/api/video/test/BUILD.gn
index 8ad1b50..64af58c 100644
--- a/api/video/test/BUILD.gn
+++ b/api/video/test/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("rtc_api_video_unittests") {
+rtc_library("rtc_api_video_unittests") {
   testonly = true
   sources = [
     "color_space_unittest.cc",
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index 795a5bb..6c64e22 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_source_set("video_codecs_api") {
+rtc_library("video_codecs_api") {
   visibility = [ "*" ]
   sources = [
     "sdp_video_format.cc",
@@ -66,7 +66,7 @@
   ]
 }
 
-rtc_static_library("builtin_video_decoder_factory") {
+rtc_library("builtin_video_decoder_factory") {
   visibility = [ "*" ]
   allow_poison = [
     "audio_codecs",  # TODO(bugs.webrtc.org/8396): Remove.
@@ -85,7 +85,7 @@
   ]
 }
 
-rtc_static_library("builtin_video_encoder_factory") {
+rtc_library("builtin_video_encoder_factory") {
   visibility = [ "*" ]
   allow_poison = [
     "audio_codecs",  # TODO(bugs.webrtc.org/8396): Remove.
@@ -108,7 +108,7 @@
   ]
 }
 
-rtc_static_library("vp8_temporal_layers_factory") {
+rtc_library("vp8_temporal_layers_factory") {
   visibility = [ "*" ]
   allow_poison = [ "software_video_codecs" ]
   sources = [
@@ -125,7 +125,7 @@
   ]
 }
 
-rtc_static_library("rtc_software_fallback_wrappers") {
+rtc_library("rtc_software_fallback_wrappers") {
   visibility = [ "*" ]
 
   sources = [
diff --git a/api/video_codecs/test/BUILD.gn b/api/video_codecs/test/BUILD.gn
index d57cbbb..e317264 100644
--- a/api/video_codecs/test/BUILD.gn
+++ b/api/video_codecs/test/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_source_set("video_codecs_api_unittests") {
+  rtc_library("video_codecs_api_unittests") {
     testonly = true
     sources = [
       "builtin_video_encoder_factory_unittest.cc",
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index ba4518d..5bb7b8c 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_static_library("audio") {
+rtc_library("audio") {
   sources = [
     "audio_level.cc",
     "audio_level.h",
@@ -92,7 +92,7 @@
   ]
 }
 if (rtc_include_tests) {
-  rtc_source_set("audio_end_to_end_test") {
+  rtc_library("audio_end_to_end_test") {
     testonly = true
 
     sources = [
@@ -111,7 +111,7 @@
     ]
   }
 
-  rtc_source_set("audio_tests") {
+  rtc_library("audio_tests") {
     testonly = true
 
     sources = [
@@ -255,7 +255,7 @@
     }
   }
 
-  rtc_source_set("audio_perf_tests") {
+  rtc_library("audio_perf_tests") {
     testonly = true
 
     sources = [
diff --git a/audio/utility/BUILD.gn b/audio/utility/BUILD.gn
index f4c8fa7..721b450 100644
--- a/audio/utility/BUILD.gn
+++ b/audio/utility/BUILD.gn
@@ -13,7 +13,7 @@
   ]
 }
 
-rtc_static_library("audio_frame_operations") {
+rtc_library("audio_frame_operations") {
   visibility = [ "*" ]
   sources = [
     "audio_frame_operations.cc",
@@ -34,7 +34,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("utility_tests") {
+  rtc_library("utility_tests") {
     testonly = true
     sources = [
       "audio_frame_operations_unittest.cc",
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 9db341b..7d85196 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../webrtc.gni")
 
-rtc_source_set("call_interfaces") {
+rtc_library("call_interfaces") {
   sources = [
     "audio_receive_stream.cc",
     "audio_receive_stream.h",
@@ -64,7 +64,7 @@
 
 # TODO(nisse): These RTP targets should be moved elsewhere
 # when interfaces have stabilized. See also TODO for |mock_rtp_interfaces|.
-rtc_source_set("rtp_interfaces") {
+rtc_library("rtp_interfaces") {
   # Client code SHOULD NOT USE THIS TARGET, but for now it needs to be public
   # because there exists client code that uses it.
   # TODO(bugs.webrtc.org/9808): Move to private visibility as soon as that
@@ -93,7 +93,7 @@
   ]
 }
 
-rtc_source_set("rtp_receiver") {
+rtc_library("rtp_receiver") {
   visibility = [ "*" ]
   sources = [
     "rtcp_demuxer.cc",
@@ -120,7 +120,7 @@
   ]
 }
 
-rtc_source_set("rtp_sender") {
+rtc_library("rtp_sender") {
   sources = [
     "rtp_payload_params.cc",
     "rtp_payload_params.h",
@@ -175,7 +175,7 @@
   ]
 }
 
-rtc_source_set("bitrate_configurator") {
+rtc_library("bitrate_configurator") {
   sources = [
     "rtp_bitrate_configurator.cc",
     "rtp_bitrate_configurator.h",
@@ -192,7 +192,7 @@
   ]
 }
 
-rtc_source_set("bitrate_allocator") {
+rtc_library("bitrate_allocator") {
   sources = [
     "bitrate_allocator.cc",
     "bitrate_allocator.h",
@@ -213,7 +213,7 @@
   ]
 }
 
-rtc_static_library("call") {
+rtc_library("call") {
   sources = [
     "call.cc",
     "call_factory.cc",
@@ -275,7 +275,7 @@
   ]
 }
 
-rtc_source_set("video_stream_api") {
+rtc_library("video_stream_api") {
   sources = [
     "video_receive_stream.cc",
     "video_receive_stream.h",
@@ -304,7 +304,7 @@
   ]
 }
 
-rtc_source_set("simulated_network") {
+rtc_library("simulated_network") {
   sources = [
     "simulated_network.cc",
     "simulated_network.h",
@@ -332,7 +332,7 @@
   ]
 }
 
-rtc_source_set("fake_network") {
+rtc_library("fake_network") {
   sources = [
     "fake_network_pipe.cc",
     "fake_network_pipe.h",
@@ -353,7 +353,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("call_tests") {
+  rtc_library("call_tests") {
     testonly = true
 
     sources = [
@@ -427,7 +427,7 @@
     ]
   }
 
-  rtc_source_set("call_perf_tests") {
+  rtc_library("call_perf_tests") {
     testonly = true
 
     sources = [
@@ -520,7 +520,7 @@
     ]
   }
 
-  rtc_source_set("fake_network_pipe_unittests") {
+  rtc_library("fake_network_pipe_unittests") {
     testonly = true
 
     sources = [
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 849ecad..7c5d8b0 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -10,7 +10,7 @@
 
 visibility = [ ":*" ]
 
-rtc_static_library("common_audio") {
+rtc_library("common_audio") {
   visibility += [ "*" ]
   sources = [
     "audio_converter.cc",
@@ -101,7 +101,7 @@
   }
 }
 
-rtc_source_set("common_audio_c") {
+rtc_library("common_audio_c") {
   visibility += webrtc_default_visibility
   sources = [
     "ring_buffer.c",
@@ -193,7 +193,7 @@
   ]
 }
 
-rtc_source_set("common_audio_cc") {
+rtc_library("common_audio_cc") {
   sources = [
     "signal_processing/dot_product_with_scale.cc",
     "signal_processing/dot_product_with_scale.h",
@@ -225,7 +225,7 @@
   ]
 }
 
-rtc_source_set("fir_filter_factory") {
+rtc_library("fir_filter_factory") {
   visibility += webrtc_default_visibility
   sources = [
     "fir_filter_c.cc",
@@ -249,7 +249,7 @@
 }
 
 if (current_cpu == "x86" || current_cpu == "x64") {
-  rtc_static_library("common_audio_sse2") {
+  rtc_library("common_audio_sse2") {
     sources = [
       "fir_filter_sse.cc",
       "fir_filter_sse.h",
@@ -271,7 +271,7 @@
 }
 
 if (rtc_build_with_neon) {
-  rtc_static_library("common_audio_neon") {
+  rtc_library("common_audio_neon") {
     sources = [
       "fir_filter_neon.cc",
       "fir_filter_neon.h",
@@ -294,7 +294,7 @@
     ]
   }
 
-  rtc_source_set("common_audio_neon_c") {
+  rtc_library("common_audio_neon_c") {
     visibility += webrtc_default_visibility
     sources = [
       "signal_processing/cross_correlation_neon.c",
diff --git a/common_audio/third_party/fft4g/BUILD.gn b/common_audio/third_party/fft4g/BUILD.gn
index ae0d5f6..789df92 100644
--- a/common_audio/third_party/fft4g/BUILD.gn
+++ b/common_audio/third_party/fft4g/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("fft4g") {
+rtc_library("fft4g") {
   sources = [
     "fft4g.c",
     "fft4g.h",
diff --git a/common_audio/third_party/spl_sqrt_floor/BUILD.gn b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
index 194899e..239a859 100644
--- a/common_audio/third_party/spl_sqrt_floor/BUILD.gn
+++ b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("spl_sqrt_floor") {
+rtc_library("spl_sqrt_floor") {
   visibility = [ "../..:common_audio_c" ]
   sources = [
     "spl_sqrt_floor.h",
diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn
index c2c0bc2..d77f4b8 100644
--- a/common_video/BUILD.gn
+++ b/common_video/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../webrtc.gni")
 
-rtc_static_library("common_video") {
+rtc_library("common_video") {
   visibility = [ "*" ]
 
   sources = [
diff --git a/common_video/generic_frame_descriptor/BUILD.gn b/common_video/generic_frame_descriptor/BUILD.gn
index 6b8434e..9ea0912 100644
--- a/common_video/generic_frame_descriptor/BUILD.gn
+++ b/common_video/generic_frame_descriptor/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("generic_frame_descriptor") {
+rtc_library("generic_frame_descriptor") {
   sources = [
     "generic_frame_info.cc",
     "generic_frame_info.h",
diff --git a/common_video/test/BUILD.gn b/common_video/test/BUILD.gn
index 0522ba5..10ebbaa 100644
--- a/common_video/test/BUILD.gn
+++ b/common_video/test/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_source_set("utilities") {
+  rtc_library("utilities") {
     testonly = true
     sources = [
       "utilities.cc",
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index 0814dcf..7b69c2b 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -61,7 +61,7 @@
   }
 }
 
-rtc_source_set("read_auth_file") {
+rtc_library("read_auth_file") {
   testonly = true
   sources = [
     "turnserver/read_auth_file.cc",
@@ -190,7 +190,7 @@
     include_dirs = [ "objc/AppRTCMobile/common" ]
   }
 
-  rtc_static_library("apprtc_common") {
+  rtc_library("apprtc_common") {
     testonly = true
     sources = [
       "objc/AppRTCMobile/common/ARDUtilities.h",
@@ -219,7 +219,7 @@
     ]
   }
 
-  rtc_static_library("apprtc_signaling") {
+  rtc_library("apprtc_signaling") {
     testonly = true
     sources = [
       "objc/AppRTCMobile/ARDAppClient+Internal.h",
@@ -284,7 +284,7 @@
   }
 
   if (is_ios) {
-    rtc_static_library("AppRTCMobile_lib") {
+    rtc_library("AppRTCMobile_lib") {
       # iOS must use WebRTC.framework which is dynamically linked.
       testonly = true
       sources = [
@@ -379,7 +379,7 @@
         ]
       }
 
-      rtc_static_library("AppRTCMobileBroadcastUpload_lib") {
+      rtc_library("AppRTCMobileBroadcastUpload_lib") {
         testonly = true
         sources = [
           "objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.h",
@@ -453,7 +453,7 @@
       ]
     }
 
-    rtc_static_library("ObjCNativeAPIDemo_lib") {
+    rtc_library("ObjCNativeAPIDemo_lib") {
       testonly = true
       sources = [
         "objcnativeapi/objc/NADAppDelegate.h",
@@ -512,7 +512,7 @@
   }
 
   if (is_mac) {
-    rtc_static_library("AppRTCMobile_lib") {
+    rtc_library("AppRTCMobile_lib") {
       testonly = true
       sources = [
         "objc/AppRTCMobile/mac/APPRTCAppDelegate.h",
@@ -576,7 +576,7 @@
     ]
   }
 
-  rtc_static_library("socketrocket") {
+  rtc_library("socketrocket") {
     testonly = true
     sources = [
       "objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h",
@@ -595,7 +595,7 @@
   if (rtc_include_tests) {
     # TODO(kthelgason): compile xctests on mac when chromium supports it.
     if (is_ios) {
-      rtc_source_set("apprtcmobile_test_sources") {
+      rtc_library("apprtcmobile_test_sources") {
         # iOS must use WebRTC.framework which is dynamically linked.
         testonly = true
         include_dirs = [
diff --git a/logging/BUILD.gn b/logging/BUILD.gn
index 079cd3a..eb52c73 100644
--- a/logging/BUILD.gn
+++ b/logging/BUILD.gn
@@ -36,7 +36,7 @@
   ]
 }
 
-rtc_source_set("rtc_stream_config") {
+rtc_library("rtc_stream_config") {
   sources = [
     "rtc_event_log/rtc_stream_config.cc",
     "rtc_event_log/rtc_stream_config.h",
@@ -48,7 +48,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_pacing") {
+rtc_library("rtc_event_pacing") {
   sources = [
     "rtc_event_log/events/rtc_event_alr_state.cc",
     "rtc_event_log/events/rtc_event_alr_state.h",
@@ -61,7 +61,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_audio") {
+rtc_library("rtc_event_audio") {
   sources = [
     "rtc_event_log/events/rtc_event_audio_network_adaptation.cc",
     "rtc_event_log/events/rtc_event_audio_network_adaptation.h",
@@ -83,7 +83,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_bwe") {
+rtc_library("rtc_event_bwe") {
   sources = [
     "rtc_event_log/events/rtc_event_bwe_update_delay_based.cc",
     "rtc_event_log/events/rtc_event_bwe_update_delay_based.h",
@@ -110,7 +110,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_generic_packet_events") {
+rtc_library("rtc_event_generic_packet_events") {
   visibility = [ "*" ]
   sources = [
     "rtc_event_log/events/rtc_event_generic_ack_received.cc",
@@ -128,7 +128,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_rtp_rtcp") {
+rtc_library("rtc_event_rtp_rtcp") {
   sources = [
     "rtc_event_log/events/rtc_event_rtcp_packet_incoming.cc",
     "rtc_event_log/events/rtc_event_rtcp_packet_incoming.h",
@@ -151,7 +151,7 @@
   ]
 }
 
-rtc_source_set("rtc_event_video") {
+rtc_library("rtc_event_video") {
   sources = [
     "rtc_event_log/events/rtc_event_video_receive_stream_config.cc",
     "rtc_event_log/events/rtc_event_video_receive_stream_config.h",
@@ -170,7 +170,7 @@
 
 # TODO(eladalon): Break down into (1) encoder and (2) decoder; we don't need
 # the decoder code in the WebRTC library, only in unit tests and tools.
-rtc_static_library("rtc_event_log_impl_encoder") {
+rtc_library("rtc_event_log_impl_encoder") {
   sources = [
     "rtc_event_log/encoder/blob_encoding.cc",
     "rtc_event_log/encoder/blob_encoding.h",
@@ -235,7 +235,7 @@
 }
 
 if (rtc_enable_protobuf) {
-  rtc_source_set("rtc_event_log_impl") {
+  rtc_library("rtc_event_log_impl") {
     visibility = [ "../api/rtc_event_log:rtc_event_log_factory" ]
     sources = [
       "rtc_event_log/rtc_event_log_impl.cc",
@@ -258,7 +258,7 @@
   }
 }
 
-rtc_source_set("fake_rtc_event_log") {
+rtc_library("fake_rtc_event_log") {
   testonly = true
   sources = [
     "rtc_event_log/fake_rtc_event_log.cc",
@@ -292,7 +292,7 @@
     proto_out_dir = "logging/rtc_event_log"
   }
 
-  rtc_static_library("rtc_event_log_parser") {
+  rtc_library("rtc_event_log_parser") {
     visibility = [ "*" ]
     sources = [
       "rtc_event_log/logged_events.cc",
@@ -335,7 +335,7 @@
   }
 
   if (rtc_include_tests) {
-    rtc_source_set("rtc_event_log_tests") {
+    rtc_library("rtc_event_log_tests") {
       testonly = true
       assert(rtc_enable_protobuf)
       defines = [ "ENABLE_RTC_EVENT_LOG" ]
@@ -412,7 +412,7 @@
   }
 }
 
-rtc_source_set("ice_log") {
+rtc_library("ice_log") {
   sources = [
     "rtc_event_log/events/rtc_event_dtls_transport_state.cc",
     "rtc_event_log/events/rtc_event_dtls_transport_state.h",
@@ -436,7 +436,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("mocks") {
+  rtc_library("mocks") {
     testonly = true
     sources = [
       "rtc_event_log/mock/mock_rtc_event_log.cc",
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 39d40a7..59c2bfc 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -23,7 +23,7 @@
   defines = [ "HAVE_WEBRTC_VIDEO" ]
 }
 
-rtc_source_set("rtc_h264_profile_id") {
+rtc_library("rtc_h264_profile_id") {
   visibility = [ "*" ]
   sources = [
     "base/h264_profile_level_id.cc",
@@ -47,7 +47,7 @@
   ]
 }
 
-rtc_source_set("rtc_vp9_profile") {
+rtc_library("rtc_vp9_profile") {
   visibility = [ "*" ]
   sources = [
     "base/vp9_profile.cc",
@@ -63,7 +63,7 @@
   ]
 }
 
-rtc_static_library("rtc_media_base") {
+rtc_library("rtc_media_base") {
   visibility = [ "*" ]
   defines = []
   libs = []
@@ -144,7 +144,7 @@
   ]
 }
 
-rtc_static_library("rtc_constants") {
+rtc_library("rtc_constants") {
   defines = []
   libs = []
   deps = []
@@ -154,7 +154,7 @@
   ]
 }
 
-rtc_static_library("rtc_simulcast_encoder_adapter") {
+rtc_library("rtc_simulcast_encoder_adapter") {
   visibility = [ "*" ]
   defines = []
   libs = []
@@ -185,7 +185,7 @@
   ]
 }
 
-rtc_static_library("rtc_encoder_simulcast_proxy") {
+rtc_library("rtc_encoder_simulcast_proxy") {
   visibility = [ "*" ]
   defines = []
   libs = []
@@ -204,7 +204,7 @@
   ]
 }
 
-rtc_static_library("rtc_internal_video_codecs") {
+rtc_library("rtc_internal_video_codecs") {
   visibility = [ "*" ]
   allow_poison = [ "software_video_codecs" ]
   defines = []
@@ -253,7 +253,7 @@
   ]
 }
 
-rtc_static_library("rtc_audio_video") {
+rtc_library("rtc_audio_video") {
   visibility = [ "*" ]
   allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
   defines = []
@@ -349,7 +349,7 @@
 
 # Heavy but optional helper for unittests and webrtc users who prefer to use
 # defaults factories or do not worry about extra dependencies and binary size.
-rtc_source_set("rtc_media_engine_defaults") {
+rtc_library("rtc_media_engine_defaults") {
   visibility = [ "*" ]
   allow_poison = [
     "audio_codecs",
@@ -373,7 +373,7 @@
   ]
 }
 
-rtc_static_library("rtc_data") {
+rtc_library("rtc_data") {
   defines = [
     # "SCTP_DEBUG" # Uncomment for SCTP debugging.
   ]
@@ -425,7 +425,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("rtc_media_tests_utils") {
+  rtc_library("rtc_media_tests_utils") {
     testonly = true
 
     defines = []
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 621e64d..ece91af 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -39,7 +39,7 @@
   ]
 }
 
-rtc_source_set("module_api") {
+rtc_library("module_api") {
   visibility = [ "*" ]
   sources = [
     "include/module.h",
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 06bcbde..5eafc04 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -24,7 +24,7 @@
   ]
 }
 
-rtc_static_library("audio_coding") {
+rtc_library("audio_coding") {
   visibility += [ "*" ]
   sources = [
     "acm2/acm_receiver.cc",
@@ -61,7 +61,7 @@
   ]
 }
 
-rtc_static_library("legacy_encoded_audio_frame") {
+rtc_library("legacy_encoded_audio_frame") {
   sources = [
     "codecs/legacy_encoded_audio_frame.cc",
     "codecs/legacy_encoded_audio_frame.h",
@@ -75,7 +75,7 @@
   ]
 }
 
-rtc_static_library("webrtc_cng") {
+rtc_library("webrtc_cng") {
   visibility += webrtc_default_visibility
   sources = [
     "codecs/cng/webrtc_cng.cc",
@@ -91,7 +91,7 @@
   ]
 }
 
-rtc_static_library("audio_encoder_cng") {
+rtc_library("audio_encoder_cng") {
   visibility += [ "*" ]
   sources = [
     "codecs/cng/audio_encoder_cng.cc",
@@ -106,7 +106,7 @@
   ]
 }
 
-rtc_static_library("red") {
+rtc_library("red") {
   visibility += [ "*" ]
   sources = [
     "codecs/red/audio_encoder_copy_red.cc",
@@ -123,7 +123,7 @@
   ]
 }
 
-rtc_static_library("g711") {
+rtc_library("g711") {
   visibility += [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -145,7 +145,7 @@
   ]
 }
 
-rtc_source_set("g711_c") {
+rtc_library("g711_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/g711/g711_interface.c",
@@ -156,7 +156,7 @@
   ]
 }
 
-rtc_static_library("g722") {
+rtc_library("g722") {
   visibility += [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -179,7 +179,7 @@
   ]
 }
 
-rtc_source_set("g722_c") {
+rtc_library("g722_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/g722/g722_interface.c",
@@ -190,7 +190,7 @@
   ]
 }
 
-rtc_static_library("ilbc") {
+rtc_library("ilbc") {
   visibility += webrtc_default_visibility
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -214,7 +214,7 @@
   ]
 }
 
-rtc_source_set("ilbc_c") {
+rtc_library("ilbc_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/ilbc/abs_quant.c",
@@ -388,7 +388,7 @@
   ]
 }
 
-rtc_static_library("isac") {
+rtc_library("isac") {
   visibility += [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -414,7 +414,7 @@
   deps = []
 }
 
-rtc_source_set("isac_vad") {
+rtc_library("isac_vad") {
   visibility += webrtc_default_visibility
   sources = [
     "codecs/isac/main/source/filter_functions.c",
@@ -438,7 +438,7 @@
   ]
 }
 
-rtc_static_library("isac_c") {
+rtc_library("isac_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/isac/main/include/isac.h",
@@ -499,7 +499,7 @@
   ]
 }
 
-rtc_static_library("isac_fix") {
+rtc_library("isac_fix") {
   visibility += [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -522,7 +522,7 @@
   }
 }
 
-rtc_source_set("isac_fix_common") {
+rtc_library("isac_fix_common") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/isac/fix/source/codec.h",
@@ -556,7 +556,7 @@
   }
 }
 
-rtc_source_set("isac_fix_c") {
+rtc_library("isac_fix_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/isac/fix/include/audio_decoder_isacfix.h",
@@ -663,7 +663,7 @@
 }
 
 if (rtc_build_with_neon) {
-  rtc_static_library("isac_neon") {
+  rtc_library("isac_neon") {
     poisonous = [ "audio_codecs" ]
     sources = [
       "codecs/isac/fix/source/entropy_coding_neon.c",
@@ -689,7 +689,7 @@
   }
 }
 
-rtc_static_library("pcm16b") {
+rtc_library("pcm16b") {
   visibility += [ "*" ]
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -714,7 +714,7 @@
   ]
 }
 
-rtc_source_set("pcm16b_c") {
+rtc_library("pcm16b_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/pcm16b/pcm16b.c",
@@ -722,7 +722,7 @@
   ]
 }
 
-rtc_static_library("audio_coding_opus_common") {
+rtc_library("audio_coding_opus_common") {
   sources = [
     "codecs/opus/audio_coder_opus_common.cc",
     "codecs/opus/audio_coder_opus_common.h",
@@ -738,7 +738,7 @@
   ]
 }
 
-rtc_static_library("webrtc_opus") {
+rtc_library("webrtc_opus") {
   visibility += webrtc_default_visibility
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -777,7 +777,7 @@
   }
 }
 
-rtc_static_library("webrtc_multiopus") {
+rtc_library("webrtc_multiopus") {
   visibility += webrtc_default_visibility
   poisonous = [ "audio_codecs" ]
   sources = [
@@ -815,7 +815,7 @@
   }
 }
 
-rtc_source_set("webrtc_opus_c") {
+rtc_library("webrtc_opus_c") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "codecs/opus/opus_inst.h",
@@ -857,7 +857,7 @@
   }
 }
 
-rtc_static_library("audio_network_adaptor_config") {
+rtc_library("audio_network_adaptor_config") {
   visibility += webrtc_default_visibility
   sources = [
     "audio_network_adaptor/audio_network_adaptor_config.cc",
@@ -868,7 +868,7 @@
   ]
 }
 
-rtc_static_library("audio_network_adaptor") {
+rtc_library("audio_network_adaptor") {
   visibility += webrtc_default_visibility
   sources = [
     "audio_network_adaptor/audio_network_adaptor_impl.cc",
@@ -923,7 +923,7 @@
   }
 }
 
-rtc_static_library("neteq") {
+rtc_library("neteq") {
   visibility += webrtc_default_visibility
   sources = [
     "neteq/accelerate.cc",
@@ -1028,7 +1028,7 @@
 # rtc_include_tests conditional. The reason is that it supports fuzzer tests
 # that ultimately are built and run as a part of the Chromium ecosystem, which
 # does not set the rtc_include_tests flag.
-rtc_source_set("neteq_tools_minimal") {
+rtc_library("neteq_tools_minimal") {
   visibility += webrtc_default_visibility
   sources = [
     "neteq/tools/audio_sink.cc",
@@ -1061,7 +1061,7 @@
   defines = audio_codec_defines
 }
 
-rtc_source_set("neteq_test_tools") {
+rtc_library("neteq_test_tools") {
   visibility += webrtc_default_visibility
   testonly = true
   sources = [
@@ -1111,7 +1111,7 @@
   }
 }
 
-rtc_source_set("neteq_tools") {
+rtc_library("neteq_tools") {
   visibility += webrtc_default_visibility
   sources = [
     "neteq/tools/fake_decode_from_file.cc",
@@ -1144,7 +1144,7 @@
   ]
 }
 
-rtc_source_set("neteq_input_audio_tools") {
+rtc_library("neteq_input_audio_tools") {
   visibility += webrtc_default_visibility
   sources = [
     "neteq/tools/input_audio_file.cc",
@@ -1161,7 +1161,7 @@
 }
 
 if (rtc_enable_protobuf) {
-  rtc_static_library("rtc_event_log_source") {
+  rtc_library("rtc_event_log_source") {
     testonly = true
 
     sources = [
@@ -1255,7 +1255,7 @@
     }
   }
 
-  rtc_source_set("audio_coding_modules_tests") {
+  rtc_library("audio_coding_modules_tests") {
     testonly = true
     visibility += webrtc_default_visibility
 
@@ -1325,7 +1325,7 @@
     defines = audio_coding_defines
   }
 
-  rtc_source_set("audio_coding_perf_tests") {
+  rtc_library("audio_coding_perf_tests") {
     testonly = true
     visibility += webrtc_default_visibility
 
@@ -1346,7 +1346,7 @@
     ]
   }
 
-  rtc_source_set("acm_receive_test") {
+  rtc_library("acm_receive_test") {
     testonly = true
     sources = [
       "acm2/acm_receive_test.cc",
@@ -1369,7 +1369,7 @@
            ]
   }
 
-  rtc_source_set("acm_send_test") {
+  rtc_library("acm_send_test") {
     testonly = true
     sources = [
       "acm2/acm_send_test.cc",
@@ -1448,7 +1448,7 @@
       proto_out_dir = "modules/audio_coding/neteq"
     }
 
-    rtc_source_set("neteq_test_factory") {
+    rtc_library("neteq_test_factory") {
       testonly = true
       visibility += webrtc_default_visibility
       defines = audio_codec_defines
@@ -1546,7 +1546,7 @@
     ]
   }
 
-  rtc_source_set("neteq_test_support") {
+  rtc_library("neteq_test_support") {
     testonly = true
     sources = [
       "neteq/tools/neteq_performance_test.cc",
@@ -1569,7 +1569,7 @@
     ]
   }
 
-  rtc_source_set("neteq_quality_test_support") {
+  rtc_library("neteq_quality_test_support") {
     testonly = true
     sources = [
       "neteq/tools/neteq_quality_test.cc",
@@ -1797,7 +1797,7 @@
     ]
   }
 
-  rtc_source_set("isac_test_util") {
+  rtc_library("isac_test_util") {
     testonly = true
     sources = [
       "codecs/isac/main/util/utility.c",
@@ -1902,7 +1902,7 @@
     ]
   }
 
-  rtc_source_set("audio_coding_unittests") {
+  rtc_library("audio_coding_unittests") {
     testonly = true
     visibility += webrtc_default_visibility
 
diff --git a/modules/audio_coding/codecs/opus/test/BUILD.gn b/modules/audio_coding/codecs/opus/test/BUILD.gn
index 51b0df3..ca9c4c4 100644
--- a/modules/audio_coding/codecs/opus/test/BUILD.gn
+++ b/modules/audio_coding/codecs/opus/test/BUILD.gn
@@ -14,7 +14,7 @@
 ]
 
 if (rtc_include_tests) {
-  rtc_static_library("test") {
+  rtc_library("test") {
     testonly = true
 
     sources = [
@@ -34,7 +34,7 @@
     ]
   }
 
-  rtc_source_set("test_unittest") {
+  rtc_library("test_unittest") {
     testonly = true
 
     sources = [
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index b320148..f827341 100644
--- a/modules/audio_device/BUILD.gn
+++ b/modules/audio_device/BUILD.gn
@@ -61,7 +61,7 @@
   ]
 }
 
-rtc_source_set("audio_device_buffer") {
+rtc_library("audio_device_buffer") {
   sources = [
     "audio_device_buffer.cc",
     "audio_device_buffer.h",
@@ -82,7 +82,7 @@
   ]
 }
 
-rtc_source_set("audio_device_generic") {
+rtc_library("audio_device_generic") {
   sources = [
     "audio_device_generic.cc",
     "audio_device_generic.h",
@@ -94,7 +94,7 @@
   ]
 }
 
-rtc_source_set("audio_device_name") {
+rtc_library("audio_device_name") {
   sources = [
     "audio_device_name.cc",
     "audio_device_name.h",
@@ -155,7 +155,7 @@
 
 # Contains default implementations of webrtc::AudioDeviceModule for Windows,
 # Linux, Mac, iOS and Android.
-rtc_source_set("audio_device_impl") {
+rtc_library("audio_device_impl") {
   visibility = [ "*" ]
   deps = [
     ":audio_device_api",
@@ -364,7 +364,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("audio_device_unittests") {
+  rtc_library("audio_device_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn
index 99bc2d1..ef84bc7 100644
--- a/modules/audio_mixer/BUILD.gn
+++ b/modules/audio_mixer/BUILD.gn
@@ -15,7 +15,7 @@
   ]
 }
 
-rtc_static_library("audio_mixer_impl") {
+rtc_library("audio_mixer_impl") {
   visibility = [ "*" ]
   sources = [
     "audio_mixer_impl.cc",
@@ -55,7 +55,7 @@
   ]
 }
 
-rtc_static_library("audio_frame_manipulator") {
+rtc_library("audio_frame_manipulator") {
   visibility = [
     ":*",
     "../../modules:*",
@@ -75,7 +75,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("audio_mixer_test_utils") {
+  rtc_library("audio_mixer_test_utils") {
     testonly = true
 
     sources = [
@@ -95,7 +95,7 @@
     ]
   }
 
-  rtc_source_set("audio_mixer_unittests") {
+  rtc_library("audio_mixer_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index b37fa4c..2d71721 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -26,7 +26,7 @@
   }
 }
 
-rtc_static_library("config") {
+rtc_library("config") {
   visibility = [ ":*" ]
   sources = [
     "include/config.cc",
@@ -38,7 +38,7 @@
   ]
 }
 
-rtc_source_set("api") {
+rtc_library("api") {
   visibility = [ "*" ]
   sources = [
     "include/audio_processing.cc",
@@ -62,7 +62,7 @@
   ]
 }
 
-rtc_static_library("audio_buffer") {
+rtc_library("audio_buffer") {
   visibility = [ "*" ]
 
   configs += [ ":apm_debug_dump" ]
@@ -87,7 +87,7 @@
   ]
 }
 
-rtc_static_library("high_pass_filter") {
+rtc_library("high_pass_filter") {
   visibility = [ "*" ]
 
   sources = [
@@ -105,7 +105,7 @@
   ]
 }
 
-rtc_static_library("audio_processing") {
+rtc_library("audio_processing") {
   visibility = [ "*" ]
   configs += [ ":apm_debug_dump" ]
   sources = [
@@ -221,7 +221,7 @@
   ]
 }
 
-rtc_source_set("audio_processing_statistics") {
+rtc_library("audio_processing_statistics") {
   visibility = [ "*" ]
   sources = [
     "include/audio_processing_statistics.cc",
@@ -254,7 +254,7 @@
   ]
 }
 
-rtc_source_set("audio_generator_factory") {
+rtc_library("audio_generator_factory") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -270,7 +270,7 @@
   ]
 }
 
-rtc_source_set("file_audio_generator") {
+rtc_library("file_audio_generator") {
   sources = [
     "audio_generator/file_audio_generator.cc",
     "audio_generator/file_audio_generator.h",
@@ -343,7 +343,7 @@
   }
 }
 
-rtc_source_set("apm_logging") {
+rtc_library("apm_logging") {
   configs += [ ":apm_debug_dump" ]
   sources = [
     "logging/apm_data_dumper.cc",
@@ -392,7 +392,7 @@
     }
   }
 
-  rtc_source_set("audio_processing_unittests") {
+  rtc_library("audio_processing_unittests") {
     testonly = true
 
     configs += [ ":apm_debug_dump" ]
@@ -522,7 +522,7 @@
     }
   }
 
-  rtc_source_set("audio_processing_perf_tests") {
+  rtc_library("audio_processing_perf_tests") {
     testonly = true
 
     sources = [
@@ -540,7 +540,7 @@
     ]
   }
 
-  rtc_source_set("file_audio_generator_unittests") {
+  rtc_library("file_audio_generator_unittests") {
     testonly = true
 
     sources = [
@@ -558,7 +558,7 @@
     ]
   }
 
-  rtc_source_set("analog_mic_simulation") {
+  rtc_library("analog_mic_simulation") {
     sources = [
       "test/fake_recording_device.cc",
       "test/fake_recording_device.h",
@@ -576,7 +576,7 @@
   }
 
   if (rtc_enable_protobuf) {
-    rtc_source_set("audioproc_f_impl") {
+    rtc_library("audioproc_f_impl") {
       testonly = true
       configs += [ ":apm_debug_dump" ]
       sources = [
@@ -634,7 +634,7 @@
     }  # audioproc_f
   }
 
-  rtc_source_set("audioproc_test_utils") {
+  rtc_library("audioproc_test_utils") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -713,7 +713,7 @@
       proto_out_dir = "modules/audio_processing/test"
     }
 
-    rtc_static_library("audioproc_protobuf_utils") {
+    rtc_library("audioproc_protobuf_utils") {
       sources = [
         "test/protobuf_utils.cc",
         "test/protobuf_utils.h",
@@ -728,7 +728,7 @@
       ]
     }
 
-    rtc_static_library("runtime_settings_protobuf_utils") {
+    rtc_library("runtime_settings_protobuf_utils") {
       testonly = true
       sources = [
         "test/runtime_setting_util.cc",
diff --git a/modules/audio_processing/aec/BUILD.gn b/modules/audio_processing/aec/BUILD.gn
index 0deaba5..472ed17 100644
--- a/modules/audio_processing/aec/BUILD.gn
+++ b/modules/audio_processing/aec/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("aec") {
+rtc_library("aec") {
   configs += [ "..:apm_debug_dump" ]
   sources = [
     "aec_resampler.cc",
@@ -25,7 +25,7 @@
   ]
 }
 
-rtc_source_set("aec_core") {
+rtc_library("aec_core") {
   configs += [ "..:apm_debug_dump" ]
   sources = [
     "aec_common.h",
@@ -72,7 +72,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("aec_unittests") {
+  rtc_library("aec_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index a9026f8..0379c39 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_static_library("aec3") {
+rtc_library("aec3") {
   visibility = [ "*" ]
   configs += [ "..:apm_debug_dump" ]
   sources = [
@@ -147,7 +147,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("aec3_unittests") {
+  rtc_library("aec3_unittests") {
     testonly = true
 
     configs += [ "..:apm_debug_dump" ]
diff --git a/modules/audio_processing/aec_dump/BUILD.gn b/modules/audio_processing/aec_dump/BUILD.gn
index 419a5ec..4ab14c6 100644
--- a/modules/audio_processing/aec_dump/BUILD.gn
+++ b/modules/audio_processing/aec_dump/BUILD.gn
@@ -22,7 +22,7 @@
   ]
 }
 
-rtc_source_set("mock_aec_dump") {
+rtc_library("mock_aec_dump") {
   testonly = true
   sources = [
     "mock_aec_dump.cc",
@@ -35,7 +35,7 @@
   ]
 }
 
-rtc_source_set("mock_aec_dump_unittests") {
+rtc_library("mock_aec_dump_unittests") {
   testonly = true
 
   sources = [
@@ -52,7 +52,7 @@
 }
 
 if (rtc_enable_protobuf) {
-  rtc_source_set("aec_dump_impl") {
+  rtc_library("aec_dump_impl") {
     sources = [
       "aec_dump_impl.cc",
       "aec_dump_impl.h",
@@ -78,7 +78,7 @@
     deps += [ "../:audioproc_debug_proto" ]
   }
 
-  rtc_source_set("aec_dump_unittests") {
+  rtc_library("aec_dump_unittests") {
     testonly = true
     defines = []
     deps = [
@@ -97,7 +97,7 @@
   }
 }
 
-rtc_source_set("null_aec_dump_factory") {
+rtc_library("null_aec_dump_factory") {
   assert_no_deps = [ ":aec_dump_impl" ]
   sources = [
     "null_aec_dump_factory.cc",
diff --git a/modules/audio_processing/aecm/BUILD.gn b/modules/audio_processing/aecm/BUILD.gn
index dbb4d2f..6f1c331 100644
--- a/modules/audio_processing/aecm/BUILD.gn
+++ b/modules/audio_processing/aecm/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("aecm_core") {
+rtc_library("aecm_core") {
   sources = [
     "aecm_core.cc",
     "aecm_core.h",
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index 7e363ca..3214f01 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -14,7 +14,7 @@
   ]
 }
 
-rtc_source_set("agc") {
+rtc_library("agc") {
   sources = [
     "agc_manager_direct.cc",
     "agc_manager_direct.h",
@@ -38,7 +38,7 @@
   ]
 }
 
-rtc_source_set("level_estimation") {
+rtc_library("level_estimation") {
   sources = [
     "agc.cc",
     "agc.h",
@@ -54,7 +54,7 @@
   ]
 }
 
-rtc_source_set("agc_legacy_c") {
+rtc_library("agc_legacy_c") {
   visibility = [
     ":*",
     "..:*",
@@ -95,7 +95,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("agc_unittests") {
+  rtc_library("agc_unittests") {
     testonly = true
     sources = [
       "agc_manager_direct_unittest.cc",
diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn
index 5a8e81a..25b5767 100644
--- a/modules/audio_processing/agc2/BUILD.gn
+++ b/modules/audio_processing/agc2/BUILD.gn
@@ -15,7 +15,7 @@
   ]
 }
 
-rtc_source_set("level_estimation_agc") {
+rtc_library("level_estimation_agc") {
   sources = [
     "adaptive_mode_level_estimator_agc.cc",
     "adaptive_mode_level_estimator_agc.h",
@@ -40,7 +40,7 @@
   ]
 }
 
-rtc_source_set("adaptive_digital") {
+rtc_library("adaptive_digital") {
   sources = [
     "adaptive_agc.cc",
     "adaptive_agc.h",
@@ -71,7 +71,7 @@
   ]
 }
 
-rtc_source_set("biquad_filter") {
+rtc_library("biquad_filter") {
   visibility = [ "./*" ]
   sources = [
     "biquad_filter.cc",
@@ -83,7 +83,7 @@
   ]
 }
 
-rtc_source_set("common") {
+rtc_library("common") {
   sources = [
     "agc2_common.cc",
     "agc2_common.h",
@@ -94,7 +94,7 @@
   ]
 }
 
-rtc_source_set("fixed_digital") {
+rtc_library("fixed_digital") {
   sources = [
     "fixed_digital_level_estimator.cc",
     "fixed_digital_level_estimator.h",
@@ -120,7 +120,7 @@
   ]
 }
 
-rtc_source_set("gain_applier") {
+rtc_library("gain_applier") {
   sources = [
     "gain_applier.cc",
     "gain_applier.h",
@@ -133,7 +133,7 @@
   ]
 }
 
-rtc_source_set("noise_level_estimator") {
+rtc_library("noise_level_estimator") {
   sources = [
     "down_sampler.cc",
     "down_sampler.h",
@@ -158,7 +158,7 @@
   configs += [ "..:apm_debug_dump" ]
 }
 
-rtc_source_set("rnn_vad_with_level") {
+rtc_library("rnn_vad_with_level") {
   sources = [
     "vad_with_level.cc",
     "vad_with_level.h",
@@ -172,7 +172,7 @@
   ]
 }
 
-rtc_source_set("adaptive_digital_unittests") {
+rtc_library("adaptive_digital_unittests") {
   testonly = true
   configs += [ "..:apm_debug_dump" ]
 
@@ -197,7 +197,7 @@
   ]
 }
 
-rtc_source_set("biquad_filter_unittests") {
+rtc_library("biquad_filter_unittests") {
   testonly = true
   sources = [
     "biquad_filter_unittest.cc",
@@ -208,7 +208,7 @@
   ]
 }
 
-rtc_source_set("fixed_digital_unittests") {
+rtc_library("fixed_digital_unittests") {
   testonly = true
   configs += [ "..:apm_debug_dump" ]
 
@@ -238,7 +238,7 @@
   ]
 }
 
-rtc_source_set("noise_estimator_unittests") {
+rtc_library("noise_estimator_unittests") {
   testonly = true
   configs += [ "..:apm_debug_dump" ]
 
@@ -258,7 +258,7 @@
   ]
 }
 
-rtc_source_set("rnn_vad_with_level_unittests") {
+rtc_library("rnn_vad_with_level_unittests") {
   testonly = true
   sources = [
     "vad_with_level_unittest.cc",
@@ -270,7 +270,7 @@
   ]
 }
 
-rtc_source_set("test_utils") {
+rtc_library("test_utils") {
   testonly = true
   visibility = [
     ":*",
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 63ce0c1..71e02fb 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../../webrtc.gni")
 
-rtc_source_set("rnn_vad") {
+rtc_library("rnn_vad") {
   visibility = [ "../*" ]
   sources = [
     "auto_correlation.cc",
@@ -44,7 +44,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("test_utils") {
+  rtc_library("test_utils") {
     testonly = true
     sources = [
       "test_utils.cc",
@@ -79,7 +79,7 @@
     }
   }
 
-  rtc_source_set("unittests") {
+  rtc_library("unittests") {
     testonly = true
     sources = [
       "auto_correlation_unittest.cc",
diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn
index 298e684..89ce8d1 100644
--- a/modules/audio_processing/test/conversational_speech/BUILD.gn
+++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -29,7 +29,7 @@
   ]
 }
 
-rtc_static_library("lib") {
+rtc_library("lib") {
   testonly = true
   sources = [
     "config.cc",
@@ -55,7 +55,7 @@
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
 }
 
-rtc_source_set("unittest") {
+rtc_library("unittest") {
   testonly = true
   sources = [
     "generator_unittest.cc",
diff --git a/modules/audio_processing/utility/BUILD.gn b/modules/audio_processing/utility/BUILD.gn
index 80b2bde..745775e 100644
--- a/modules/audio_processing/utility/BUILD.gn
+++ b/modules/audio_processing/utility/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("cascaded_biquad_filter") {
+rtc_library("cascaded_biquad_filter") {
   sources = [
     "cascaded_biquad_filter.cc",
     "cascaded_biquad_filter.h",
@@ -19,7 +19,7 @@
   ]
 }
 
-rtc_source_set("block_mean_calculator") {
+rtc_library("block_mean_calculator") {
   sources = [
     "block_mean_calculator.cc",
     "block_mean_calculator.h",
@@ -30,7 +30,7 @@
   ]
 }
 
-rtc_source_set("legacy_delay_estimator") {
+rtc_library("legacy_delay_estimator") {
   sources = [
     "delay_estimator.cc",
     "delay_estimator.h",
@@ -43,7 +43,7 @@
   ]
 }
 
-rtc_source_set("ooura_fft") {
+rtc_library("ooura_fft") {
   sources = [
     "ooura_fft.cc",
     "ooura_fft.h",
@@ -85,7 +85,7 @@
   }
 }
 
-rtc_source_set("pffft_wrapper") {
+rtc_library("pffft_wrapper") {
   visibility = [ "../*" ]
   sources = [
     "pffft_wrapper.cc",
@@ -99,7 +99,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("cascaded_biquad_filter_unittest") {
+  rtc_library("cascaded_biquad_filter_unittest") {
     testonly = true
 
     sources = [
@@ -113,7 +113,7 @@
     ]
   }
 
-  rtc_source_set("block_mean_calculator_unittest") {
+  rtc_library("block_mean_calculator_unittest") {
     testonly = true
 
     sources = [
@@ -127,7 +127,7 @@
     ]
   }
 
-  rtc_source_set("legacy_delay_estimator_unittest") {
+  rtc_library("legacy_delay_estimator_unittest") {
     testonly = true
 
     sources = [
@@ -141,7 +141,7 @@
     ]
   }
 
-  rtc_source_set("pffft_wrapper_unittest") {
+  rtc_library("pffft_wrapper_unittest") {
     testonly = true
     sources = [
       "pffft_wrapper_unittest.cc",
diff --git a/modules/audio_processing/vad/BUILD.gn b/modules/audio_processing/vad/BUILD.gn
index 8eb59c9..c266929 100644
--- a/modules/audio_processing/vad/BUILD.gn
+++ b/modules/audio_processing/vad/BUILD.gn
@@ -7,7 +7,7 @@
 # be found in the AUTHORS file in the root of the source tree.
 
 import("../../../webrtc.gni")
-rtc_static_library("vad") {
+rtc_library("vad") {
   visibility = [
     "../*",
     "../../../rtc_tools:*",
@@ -45,7 +45,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("vad_unittests") {
+  rtc_library("vad_unittests") {
     testonly = true
     sources = [
       "gmm_unittest.cc",
diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn
index 3f2f5d9..5a3378e 100644
--- a/modules/congestion_controller/BUILD.gn
+++ b/modules/congestion_controller/BUILD.gn
@@ -16,7 +16,7 @@
   }
 }
 
-rtc_static_library("congestion_controller") {
+rtc_library("congestion_controller") {
   visibility = [ "*" ]
   configs += [ ":bwe_test_logging" ]
   sources = [
@@ -39,7 +39,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("congestion_controller_unittests") {
+  rtc_library("congestion_controller_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/congestion_controller/bbr/BUILD.gn b/modules/congestion_controller/bbr/BUILD.gn
index f44f2bf..a17307f 100644
--- a/modules/congestion_controller/bbr/BUILD.gn
+++ b/modules/congestion_controller/bbr/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_static_library("bbr") {
+rtc_library("bbr") {
   sources = [
     "bbr_factory.cc",
     "bbr_factory.h",
@@ -21,7 +21,7 @@
   ]
 }
 
-rtc_source_set("bbr_controller") {
+rtc_library("bbr_controller") {
   visibility = [ ":*" ]
   sources = [
     "bbr_network_controller.cc",
@@ -42,7 +42,7 @@
   ]
 }
 
-rtc_source_set("bandwidth_sampler") {
+rtc_library("bandwidth_sampler") {
   visibility = [ ":*" ]
   sources = [
     "bandwidth_sampler.cc",
@@ -60,7 +60,7 @@
   ]
 }
 
-rtc_source_set("data_transfer_tracker") {
+rtc_library("data_transfer_tracker") {
   visibility = [ ":*" ]
   sources = [
     "data_transfer_tracker.cc",
@@ -85,7 +85,7 @@
   ]
 }
 
-rtc_source_set("loss_rate_filter") {
+rtc_library("loss_rate_filter") {
   visibility = [ ":*" ]
   sources = [
     "loss_rate_filter.cc",
@@ -95,7 +95,7 @@
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
-rtc_source_set("rtt_stats") {
+rtc_library("rtt_stats") {
   visibility = [ ":*" ]
   sources = [
     "rtt_stats.cc",
@@ -115,7 +115,7 @@
   ]
 }
 if (rtc_include_tests) {
-  rtc_source_set("bbr_unittests") {
+  rtc_library("bbr_unittests") {
     testonly = true
     sources = [
       "bandwidth_sampler_unittest.cc",
diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn
index 7454c97..096d7e4 100644
--- a/modules/congestion_controller/goog_cc/BUILD.gn
+++ b/modules/congestion_controller/goog_cc/BUILD.gn
@@ -16,7 +16,7 @@
   }
 }
 
-rtc_static_library("goog_cc") {
+rtc_library("goog_cc") {
   configs += [ ":bwe_test_logging" ]
   sources = [
     "goog_cc_network_control.cc",
@@ -55,7 +55,7 @@
   ]
 }
 
-rtc_source_set("link_capacity_estimator") {
+rtc_library("link_capacity_estimator") {
   sources = [
     "link_capacity_estimator.cc",
     "link_capacity_estimator.h",
@@ -67,7 +67,7 @@
   ]
 }
 
-rtc_source_set("pushback_controller") {
+rtc_library("pushback_controller") {
   sources = [
     "congestion_window_pushback_controller.cc",
     "congestion_window_pushback_controller.h",
@@ -82,7 +82,7 @@
   ]
 }
 
-rtc_source_set("alr_detector") {
+rtc_library("alr_detector") {
   sources = [
     "alr_detector.cc",
     "alr_detector.h",
@@ -101,7 +101,7 @@
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
-rtc_source_set("estimators") {
+rtc_library("estimators") {
   configs += [ ":bwe_test_logging" ]
   sources = [
     "acknowledged_bitrate_estimator.cc",
@@ -137,7 +137,7 @@
   ]
 }
 
-rtc_static_library("loss_based_controller") {
+rtc_library("loss_based_controller") {
   configs += [ ":bwe_test_logging" ]
   sources = [
     "loss_based_bandwidth_estimation.cc",
@@ -162,7 +162,7 @@
   ]
 }
 
-rtc_source_set("delay_based_bwe") {
+rtc_library("delay_based_bwe") {
   configs += [ ":bwe_test_logging" ]
   sources = [
     "delay_based_bwe.cc",
@@ -187,7 +187,7 @@
   ]
 }
 
-rtc_source_set("probe_controller") {
+rtc_library("probe_controller") {
   sources = [
     "probe_controller.cc",
     "probe_controller.h",
@@ -214,7 +214,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("test_goog_cc_printer") {
+  rtc_library("test_goog_cc_printer") {
     testonly = true
     sources = [
       "test/goog_cc_printer.cc",
@@ -235,7 +235,7 @@
       "//third_party/abseil-cpp/absl/types:optional",
     ]
   }
-  rtc_source_set("goog_cc_unittests") {
+  rtc_library("goog_cc_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/congestion_controller/pcc/BUILD.gn b/modules/congestion_controller/pcc/BUILD.gn
index 6a2f764..d011172 100644
--- a/modules/congestion_controller/pcc/BUILD.gn
+++ b/modules/congestion_controller/pcc/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_static_library("pcc") {
+rtc_library("pcc") {
   sources = [
     "pcc_factory.cc",
     "pcc_factory.h",
@@ -21,7 +21,7 @@
   ]
 }
 
-rtc_static_library("pcc_controller") {
+rtc_library("pcc_controller") {
   sources = [
     "pcc_network_controller.cc",
     "pcc_network_controller.h",
@@ -41,7 +41,7 @@
   ]
 }
 
-rtc_static_library("monitor_interval") {
+rtc_library("monitor_interval") {
   sources = [
     "monitor_interval.cc",
     "monitor_interval.h",
@@ -56,7 +56,7 @@
   ]
 }
 
-rtc_static_library("rtt_tracker") {
+rtc_library("rtt_tracker") {
   sources = [
     "rtt_tracker.cc",
     "rtt_tracker.h",
@@ -69,7 +69,7 @@
   ]
 }
 
-rtc_static_library("utility_function") {
+rtc_library("utility_function") {
   sources = [
     "utility_function.cc",
     "utility_function.h",
@@ -83,7 +83,7 @@
   ]
 }
 
-rtc_static_library("bitrate_controller") {
+rtc_library("bitrate_controller") {
   sources = [
     "bitrate_controller.cc",
     "bitrate_controller.h",
@@ -99,7 +99,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("pcc_unittests") {
+  rtc_library("pcc_unittests") {
     testonly = true
     sources = [
       "bitrate_controller_unittest.cc",
diff --git a/modules/congestion_controller/rtp/BUILD.gn b/modules/congestion_controller/rtp/BUILD.gn
index 77990b2..3e21c3a 100644
--- a/modules/congestion_controller/rtp/BUILD.gn
+++ b/modules/congestion_controller/rtp/BUILD.gn
@@ -16,7 +16,7 @@
   }
 }
 
-rtc_source_set("control_handler") {
+rtc_library("control_handler") {
   visibility = [ "*" ]
   sources = [
     "control_handler.cc",
@@ -40,7 +40,7 @@
     deps += [ "../../../rtc_base" ]
   }
 }
-rtc_static_library("transport_feedback") {
+rtc_library("transport_feedback") {
   visibility = [ "*" ]
   sources = [
     "transport_feedback_adapter.cc",
@@ -63,7 +63,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("congestion_controller_unittests") {
+  rtc_library("congestion_controller_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index bf2da63..b72bf7e 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -13,7 +13,7 @@
 
 use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
 
-rtc_static_library("primitives") {
+rtc_library("primitives") {
   visibility = [ "*" ]
   sources = [
     "desktop_capture_types.h",
@@ -41,7 +41,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("desktop_capture_modules_tests") {
+  rtc_library("desktop_capture_modules_tests") {
     testonly = true
 
     sources = []
@@ -70,7 +70,7 @@
     }
   }
 
-  rtc_source_set("desktop_capture_unittests") {
+  rtc_library("desktop_capture_unittests") {
     testonly = true
 
     sources = [
@@ -115,7 +115,7 @@
     }
   }
 
-  rtc_source_set("screen_drawer") {
+  rtc_library("screen_drawer") {
     testonly = true
 
     public_deps = [
@@ -146,7 +146,7 @@
     }
   }
 
-  rtc_source_set("desktop_capture_mock") {
+  rtc_library("desktop_capture_mock") {
     testonly = true
 
     public_deps = [
@@ -216,7 +216,7 @@
 }
 
 if (is_mac) {
-  rtc_source_set("desktop_capture_objc") {
+  rtc_library("desktop_capture_objc") {
     visibility = [ ":desktop_capture" ]
     sources = [
       "mac/desktop_configuration.mm",
@@ -252,7 +252,7 @@
   }
 }
 
-rtc_static_library("desktop_capture_generic") {
+rtc_library("desktop_capture_generic") {
   visibility = [
     ":desktop_capture",
     ":desktop_capture_objc",
@@ -486,7 +486,7 @@
 if (use_desktop_capture_differ_sse2) {
   # Have to be compiled as a separate target because it needs to be compiled
   # with SSE2 enabled.
-  rtc_static_library("desktop_capture_differ_sse2") {
+  rtc_library("desktop_capture_differ_sse2") {
     visibility = [ ":*" ]
     sources = [
       "differ_vector_sse2.cc",
diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn
index 816cec8..5166cab 100644
--- a/modules/pacing/BUILD.gn
+++ b/modules/pacing/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_static_library("pacing") {
+rtc_library("pacing") {
   # Client code SHOULD NOT USE THIS TARGET, but for now it needs to be public
   # because there exists client code that uses it.
   # TODO(bugs.webrtc.org/9808): Move to private visibility as soon as that
@@ -56,7 +56,7 @@
   ]
 }
 
-rtc_source_set("interval_budget") {
+rtc_library("interval_budget") {
   sources = [
     "interval_budget.cc",
     "interval_budget.h",
@@ -69,7 +69,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("pacing_unittests") {
+  rtc_library("pacing_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn
index aa046d5..b47d98d 100644
--- a/modules/remote_bitrate_estimator/BUILD.gn
+++ b/modules/remote_bitrate_estimator/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_static_library("remote_bitrate_estimator") {
+rtc_library("remote_bitrate_estimator") {
   visibility = [ "*" ]
   sources = [
     "aimd_rate_control.cc",
@@ -64,7 +64,7 @@
 }
 
 if (!build_with_chromium) {
-  rtc_source_set("bwe_rtp") {
+  rtc_library("bwe_rtp") {
     testonly = true
     sources = [
       "tools/bwe_rtp.cc",
@@ -96,7 +96,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("remote_bitrate_estimator_unittests") {
+  rtc_library("remote_bitrate_estimator_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index f421100..fb1aca3 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("rtp_rtcp_format") {
+rtc_library("rtp_rtcp_format") {
   visibility = [ "*" ]
   public = [
     "include/report_block_data.h",
@@ -124,7 +124,7 @@
   ]
 }
 
-rtc_static_library("rtp_rtcp") {
+rtc_library("rtp_rtcp") {
   visibility = [ "*" ]
   sources = [
     "include/flexfec_receiver.h",
@@ -272,7 +272,7 @@
   ]
 }
 
-rtc_source_set("rtcp_transceiver") {
+rtc_library("rtcp_transceiver") {
   visibility = [ "*" ]
   public = [
     "source/rtcp_transceiver.h",
@@ -304,7 +304,7 @@
   ]
 }
 
-rtc_source_set("rtp_video_header") {
+rtc_library("rtp_video_header") {
   visibility = [ "*" ]
   sources = [
     "source/rtp_video_header.cc",
@@ -322,7 +322,7 @@
   ]
 }
 
-rtc_source_set("fec_test_helper") {
+rtc_library("fec_test_helper") {
   testonly = true
   sources = [
     "source/fec_test_helper.cc",
@@ -337,7 +337,7 @@
   ]
 }
 
-rtc_source_set("mock_rtp_rtcp") {
+rtc_library("mock_rtp_rtcp") {
   testonly = true
   sources = [
     "mocks/mock_recovered_packet_receiver.cc",
@@ -381,7 +381,7 @@
     ]
   }  # test_packet_masks_metrics
 
-  rtc_source_set("rtp_rtcp_modules_tests") {
+  rtc_library("rtp_rtcp_modules_tests") {
     testonly = true
 
     sources = [
@@ -396,7 +396,7 @@
     ]
   }
 
-  rtc_source_set("rtp_rtcp_unittests") {
+  rtc_library("rtp_rtcp_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/third_party/fft/BUILD.gn b/modules/third_party/fft/BUILD.gn
index ad51341..49dbd6f 100644
--- a/modules/third_party/fft/BUILD.gn
+++ b/modules/third_party/fft/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("fft") {
+rtc_library("fft") {
   sources = [
     "fft.c",
     "fft.h",
diff --git a/modules/third_party/g711/BUILD.gn b/modules/third_party/g711/BUILD.gn
index ca1ccf3..f7735a6 100644
--- a/modules/third_party/g711/BUILD.gn
+++ b/modules/third_party/g711/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("g711_3p") {
+rtc_library("g711_3p") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "g711.c",
diff --git a/modules/third_party/g722/BUILD.gn b/modules/third_party/g722/BUILD.gn
index a1bfe89..316cdc7 100644
--- a/modules/third_party/g722/BUILD.gn
+++ b/modules/third_party/g722/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("g722_3p") {
+rtc_library("g722_3p") {
   poisonous = [ "audio_codecs" ]
   sources = [
     "g722_decode.c",
diff --git a/modules/third_party/portaudio/BUILD.gn b/modules/third_party/portaudio/BUILD.gn
index 1f701db..c49c544 100644
--- a/modules/third_party/portaudio/BUILD.gn
+++ b/modules/third_party/portaudio/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("mac_portaudio") {
+rtc_library("mac_portaudio") {
   visibility = [ "../../audio_device:*" ]
   sources = [
     "pa_memorybarrier.h",
diff --git a/modules/utility/BUILD.gn b/modules/utility/BUILD.gn
index f23e08b..96897ba 100644
--- a/modules/utility/BUILD.gn
+++ b/modules/utility/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_static_library("utility") {
+rtc_library("utility") {
   visibility = [ "*" ]
   sources = [
     "include/helpers_android.h",
@@ -35,7 +35,7 @@
   ]
 }
 
-rtc_source_set("mock_process_thread") {
+rtc_library("mock_process_thread") {
   testonly = true
   visibility = [ "*" ]
   sources = [
@@ -49,7 +49,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("utility_unittests") {
+  rtc_library("utility_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a085744..c3b50ef 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -12,7 +12,7 @@
 # Targets must link with either 'video_capture' or
 # 'video_capture_internal_impl' depending on whether they want to
 # use the internal capturer.
-rtc_static_library("video_capture_module") {
+rtc_library("video_capture_module") {
   visibility = [ "*" ]
   sources = [
     "device_info_impl.cc",
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 8e532d8..2bbc930 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_static_library("encoded_frame") {
+rtc_library("encoded_frame") {
   visibility = [ "*" ]
   sources = [
     "encoded_frame.cc",
@@ -34,7 +34,7 @@
   ]
 }
 
-rtc_static_library("nack_module") {
+rtc_library("nack_module") {
   visibility = [ "*" ]
   sources = [
     "histogram.cc",
@@ -55,7 +55,7 @@
   ]
 }
 
-rtc_static_library("packet") {
+rtc_library("packet") {
   visibility = [ "*" ]
   sources = [
     "packet.cc",
@@ -73,7 +73,7 @@
   ]
 }
 
-rtc_static_library("video_coding") {
+rtc_library("video_coding") {
   visibility = [ "*" ]
   deps = [
     "..:module_fec_api",
@@ -174,7 +174,7 @@
   ]
 }
 
-rtc_source_set("video_codec_interface") {
+rtc_library("video_codec_interface") {
   visibility = [ "*" ]
   sources = [
     "include/video_codec_interface.cc",
@@ -196,7 +196,7 @@
   ]
 }
 
-rtc_source_set("video_coding_legacy") {
+rtc_library("video_coding_legacy") {
   visibility = [ ":video_coding_unittests" ]
   sources = [
     "decoding_state.cc",
@@ -257,7 +257,7 @@
   ]
 }
 
-rtc_source_set("video_coding_utility") {
+rtc_library("video_coding_utility") {
   visibility = [ "*" ]
   sources = [
     "utility/decoded_frames_history.cc",
@@ -311,7 +311,7 @@
   ]
 }
 
-rtc_static_library("webrtc_h264") {
+rtc_library("webrtc_h264") {
   visibility = [ "*" ]
   sources = [
     "codecs/h264/h264.cc",
@@ -357,7 +357,7 @@
   }
 }
 
-rtc_static_library("webrtc_multiplex") {
+rtc_library("webrtc_multiplex") {
   sources = [
     "codecs/multiplex/augmented_video_frame_buffer.cc",
     "codecs/multiplex/include/augmented_video_frame_buffer.h",
@@ -388,7 +388,7 @@
 }
 
 # This target includes the internal SW codec.
-rtc_static_library("webrtc_vp8") {
+rtc_library("webrtc_vp8") {
   visibility = [ "*" ]
   poisonous = [ "software_video_codecs" ]
   sources = [
@@ -434,7 +434,7 @@
   }
 }
 
-rtc_static_library("webrtc_vp8_temporal_layers") {
+rtc_library("webrtc_vp8_temporal_layers") {
   visibility = [ "*" ]
   sources = [
     "codecs/vp8/default_temporal_layers.cc",
@@ -464,7 +464,7 @@
 }
 
 # This target includes VP9 files that may be used for any VP9 codec, internal SW or external HW.
-rtc_static_library("webrtc_vp9_helpers") {
+rtc_library("webrtc_vp9_helpers") {
   sources = [
     "codecs/vp9/svc_config.cc",
     "codecs/vp9/svc_config.h",
@@ -487,7 +487,7 @@
   ]
 }
 
-rtc_static_library("webrtc_vp9") {
+rtc_library("webrtc_vp9") {
   visibility = [ "*" ]
   poisonous = [ "software_video_codecs" ]
   sources = [
@@ -528,7 +528,7 @@
 
 if (rtc_include_tests) {
   if (is_android) {
-    rtc_static_library("android_codec_factory_helper") {
+    rtc_library("android_codec_factory_helper") {
       sources = [
         "codecs/test/android_codec_factory_helper.cc",
         "codecs/test/android_codec_factory_helper.h",
@@ -547,7 +547,7 @@
   }
 
   if (is_ios || is_mac) {
-    rtc_static_library("objc_codec_factory_helper") {
+    rtc_library("objc_codec_factory_helper") {
       sources = [
         "codecs/test/objc_codec_factory_helper.h",
         "codecs/test/objc_codec_factory_helper.mm",
@@ -570,7 +570,7 @@
     }
   }
 
-  rtc_source_set("simulcast_test_fixture_impl") {
+  rtc_library("simulcast_test_fixture_impl") {
     testonly = true
     sources = [
       "utility/simulcast_test_fixture_impl.cc",
@@ -597,7 +597,7 @@
     ]
   }
 
-  rtc_source_set("video_codecs_test_framework") {
+  rtc_library("video_codecs_test_framework") {
     testonly = true
     sources = [
       "codecs/test/video_codec_unittest.cc",
@@ -676,7 +676,7 @@
     }
   }
 
-  rtc_source_set("videocodec_test_impl") {
+  rtc_library("videocodec_test_impl") {
     testonly = true
     sources = [
       "codecs/test/videocodec_test_fixture_impl.cc",
@@ -715,7 +715,7 @@
     ]
   }
 
-  rtc_source_set("videocodec_test_stats_impl") {
+  rtc_library("videocodec_test_stats_impl") {
     testonly = true
     sources = [
       "codecs/test/videocodec_test_stats_impl.cc",
@@ -731,7 +731,7 @@
     ]
   }
 
-  rtc_source_set("video_coding_modules_tests") {
+  rtc_library("video_coding_modules_tests") {
     testonly = true
     defines = []
 
@@ -812,7 +812,7 @@
     }
   }
 
-  rtc_source_set("video_coding_unittests") {
+  rtc_library("video_coding_unittests") {
     testonly = true
 
     sources = [
diff --git a/modules/video_processing/BUILD.gn b/modules/video_processing/BUILD.gn
index 003a7dd..a73ac47 100644
--- a/modules/video_processing/BUILD.gn
+++ b/modules/video_processing/BUILD.gn
@@ -10,7 +10,7 @@
 
 build_video_processing_sse2 = current_cpu == "x86" || current_cpu == "x64"
 
-rtc_static_library("video_processing") {
+rtc_library("video_processing") {
   visibility = [ "*" ]
   sources = [
     "util/denoiser_filter.cc",
@@ -60,7 +60,7 @@
 }
 
 if (build_video_processing_sse2) {
-  rtc_static_library("video_processing_sse2") {
+  rtc_library("video_processing_sse2") {
     sources = [
       "util/denoiser_filter_sse2.cc",
       "util/denoiser_filter_sse2.h",
@@ -79,7 +79,7 @@
 }
 
 if (rtc_build_with_neon) {
-  rtc_static_library("video_processing_neon") {
+  rtc_library("video_processing_neon") {
     sources = [
       "util/denoiser_filter_neon.cc",
       "util/denoiser_filter_neon.h",
@@ -97,7 +97,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("video_processing_unittests") {
+  rtc_library("video_processing_unittests") {
     testonly = true
 
     sources = [
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 913560d..0b3d28c 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -15,7 +15,7 @@
   ]
 }
 
-rtc_source_set("stun_types") {
+rtc_library("stun_types") {
   sources = [
     "base/stun.cc",
     "base/stun.h",
@@ -27,7 +27,7 @@
   ]
 }
 
-rtc_static_library("rtc_p2p") {
+rtc_library("rtc_p2p") {
   visibility = [ "*" ]
   sources = [
     "base/async_stun_tcp_socket.cc",
@@ -126,7 +126,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("fake_ice_transport") {
+  rtc_library("fake_ice_transport") {
     testonly = true
     visibility = [ "*" ]
     sources = [
@@ -141,7 +141,7 @@
     ]
   }
 
-  rtc_source_set("fake_port_allocator") {
+  rtc_library("fake_port_allocator") {
     testonly = true
     visibility = [ "*" ]
     sources = [
@@ -153,7 +153,7 @@
     ]
   }
 
-  rtc_source_set("p2p_test_utils") {
+  rtc_library("p2p_test_utils") {
     testonly = true
     sources = [
       "base/fake_dtls_transport.h",
@@ -186,7 +186,7 @@
     ]
   }
 
-  rtc_source_set("rtc_p2p_unittests") {
+  rtc_library("rtc_p2p_unittests") {
     testonly = true
 
     sources = [
@@ -241,7 +241,7 @@
   }
 }
 
-rtc_source_set("p2p_server_utils") {
+rtc_library("p2p_server_utils") {
   testonly = true
   sources = [
     "base/relay_server.cc",
@@ -263,7 +263,7 @@
   ]
 }
 
-rtc_static_library("libstunprober") {
+rtc_library("libstunprober") {
   visibility = [ "*" ]
   sources = [
     "stunprober/stun_prober.cc",
@@ -281,7 +281,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("libstunprober_unittests") {
+  rtc_library("libstunprober_unittests") {
     testonly = true
 
     sources = [
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 7a0ff31..0da5150 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -25,7 +25,7 @@
   }
 }
 
-rtc_static_library("rtc_pc_base") {
+rtc_library("rtc_pc_base") {
   visibility = [ "*" ]
   defines = []
   sources = [
@@ -147,14 +147,14 @@
   ]
 }
 
-rtc_source_set("media_protocol_names") {
+rtc_library("media_protocol_names") {
   sources = [
     "media_protocol_names.cc",
     "media_protocol_names.h",
   ]
 }
 
-rtc_static_library("peerconnection") {
+rtc_library("peerconnection") {
   visibility = [ "*" ]
   cflags = []
   sources = [
@@ -360,7 +360,7 @@
     }
   }
 
-  rtc_source_set("peerconnection_perf_tests") {
+  rtc_library("peerconnection_perf_tests") {
     testonly = true
     sources = [
       "peer_connection_rampup_tests.cc",
@@ -398,7 +398,7 @@
     ]
   }
 
-  rtc_source_set("peerconnection_wrapper") {
+  rtc_library("peerconnection_wrapper") {
     testonly = true
     sources = [
       "peer_connection_wrapper.cc",
@@ -421,7 +421,7 @@
     ]
   }
 
-  rtc_source_set("pc_test_utils") {
+  rtc_library("pc_test_utils") {
     testonly = true
     sources = [
       "test/fake_audio_capture_module.cc",
@@ -644,7 +644,7 @@
   }
 
   if (is_android) {
-    rtc_source_set("android_black_magic") {
+    rtc_library("android_black_magic") {
       # The android code uses hacky includes to chromium-base and the ssl code;
       # having this in a separate target enables us to keep the peerconnection
       # unit tests clean.
diff --git a/presubmit_test.py b/presubmit_test.py
index d6e5129..287071c 100755
--- a/presubmit_test.py
+++ b/presubmit_test.py
@@ -160,7 +160,7 @@
 
   def testNoErrorIfSourcesAreInExclusiveIfBranches(self):
     self._GenerateBuildFile(textwrap.dedent("""
-      rtc_source_set("bar_foo") {
+      rtc_library("bar_foo") {
         if (is_win) {
           sources = [
             "bar.cc",
@@ -172,7 +172,7 @@
           ],
         }
       }
-      rtc_source_set("foo_bar") {
+      rtc_library("foo_bar") {
         if (is_win) {
           sources = [
             "foo.cc",
@@ -193,7 +193,7 @@
 
   def testErrorIfSourcesAreNotInExclusiveIfBranches(self):
     self._GenerateBuildFile(textwrap.dedent("""
-      rtc_source_set("bar_foo") {
+      rtc_library("bar_foo") {
         if (is_win) {
           sources = [
             "bar.cc",
@@ -205,7 +205,7 @@
           ],
         }
       }
-      rtc_source_set("foo_bar") {
+      rtc_library("foo_bar") {
         if (is_win) {
           sources = [
             "foo.cc",
@@ -246,7 +246,7 @@
           "%s",
         ],
       }
-      rtc_source_set("foo_bar") {
+      rtc_library("foo_bar") {
         sources = [
           "%s",
           "%s",
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 896076b..9f6f148 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -48,7 +48,7 @@
 # The subset of rtc_base approved for use outside of libjingle.
 # TODO(bugs.webrtc.org/9838): Create small and focused build targets and remove
 # the old concept of rtc_base and rtc_base_approved.
-rtc_source_set("rtc_base_approved") {
+rtc_library("rtc_base_approved") {
   visibility = [ "*" ]
   deps = [
     ":checks",
@@ -156,7 +156,7 @@
   ]
 }
 
-rtc_source_set("platform_thread_types") {
+rtc_library("platform_thread_types") {
   sources = [
     "platform_thread_types.cc",
     "platform_thread_types.h",
@@ -176,7 +176,7 @@
   ]
 }
 
-rtc_source_set("criticalsection") {
+rtc_library("criticalsection") {
   sources = [
     "critical_section.cc",
     "critical_section.h",
@@ -190,7 +190,7 @@
   ]
 }
 
-rtc_source_set("platform_thread") {
+rtc_library("platform_thread") {
   visibility = [
     ":rtc_base_approved",
     ":rtc_task_queue_libevent",
@@ -214,7 +214,7 @@
   ]
 }
 
-rtc_source_set("rtc_event") {
+rtc_library("rtc_event") {
   if (build_with_chromium) {
     sources = [
       "../../webrtc_overrides/rtc_base/event.cc",
@@ -238,7 +238,7 @@
   }
 }
 
-rtc_source_set("logging") {
+rtc_library("logging") {
   visibility = [ "*" ]
   libs = []
   deps = [
@@ -301,7 +301,7 @@
   ]
 }
 
-rtc_source_set("checks") {
+rtc_library("checks") {
   # TODO(bugs.webrtc.org/9607): This should not be public.
   visibility = [ "*" ]
   libs = []
@@ -321,7 +321,7 @@
   }
 }
 
-rtc_source_set("rate_limiter") {
+rtc_library("rate_limiter") {
   sources = [
     "rate_limiter.cc",
     "rate_limiter.h",
@@ -382,7 +382,7 @@
   ]
 }
 
-rtc_source_set("timeutils") {
+rtc_library("timeutils") {
   visibility = [ "*" ]
   sources = [
     "time_utils.cc",
@@ -400,7 +400,7 @@
   }
 }
 
-rtc_source_set("stringutils") {
+rtc_library("stringutils") {
   sources = [
     "string_encode.cc",
     "string_encode.h",
@@ -421,7 +421,7 @@
   ]
 }
 
-rtc_source_set("audio_format_to_string") {
+rtc_library("audio_format_to_string") {
   sources = [
     "strings/audio_format_to_string.cc",
     "strings/audio_format_to_string.h",
@@ -444,7 +444,7 @@
   ]
 }
 
-rtc_source_set("rtc_task_queue") {
+rtc_library("rtc_task_queue") {
   visibility = [ "*" ]
   sources = [
     "task_queue.cc",
@@ -460,7 +460,7 @@
 }
 
 if (rtc_enable_libevent) {
-  rtc_source_set("rtc_task_queue_libevent") {
+  rtc_library("rtc_task_queue_libevent") {
     visibility = [ "../api/task_queue:default_task_queue_factory" ]
     sources = [
       "task_queue_libevent.cc",
@@ -485,7 +485,7 @@
 }
 
 if (is_mac || is_ios) {
-  rtc_source_set("rtc_task_queue_gcd") {
+  rtc_library("rtc_task_queue_gcd") {
     visibility = [ "../api/task_queue:default_task_queue_factory" ]
     sources = [
       "task_queue_gcd.cc",
@@ -501,7 +501,7 @@
 }
 
 if (is_win) {
-  rtc_source_set("rtc_task_queue_win") {
+  rtc_library("rtc_task_queue_win") {
     visibility = [ "../api/task_queue:default_task_queue_factory" ]
     sources = [
       "task_queue_win.cc",
@@ -522,7 +522,7 @@
   }
 }
 
-rtc_source_set("rtc_task_queue_stdlib") {
+rtc_library("rtc_task_queue_stdlib") {
   sources = [
     "task_queue_stdlib.cc",
     "task_queue_stdlib.h",
@@ -541,7 +541,7 @@
   ]
 }
 
-rtc_static_library("weak_ptr") {
+rtc_library("weak_ptr") {
   sources = [
     "weak_ptr.cc",
     "weak_ptr.h",
@@ -553,7 +553,7 @@
   ]
 }
 
-rtc_static_library("rtc_numerics") {
+rtc_library("rtc_numerics") {
   sources = [
     "numerics/exp_filter.cc",
     "numerics/exp_filter.h",
@@ -592,7 +592,7 @@
   }
 }
 
-rtc_source_set("rtc_json") {
+rtc_library("rtc_json") {
   public_configs = [ ":rtc_json_suppressions" ]
   defines = []
   sources = [
@@ -752,7 +752,7 @@
   }
 }
 
-rtc_static_library("rtc_base") {
+rtc_library("rtc_base") {
   visibility = [ "*" ]
   cflags = []
   cflags_cc = []
@@ -984,7 +984,7 @@
   ]
 }
 
-rtc_source_set("gunit_helpers") {
+rtc_library("gunit_helpers") {
   testonly = true
   sources = [
     "gunit.cc",
@@ -1000,7 +1000,7 @@
   ]
 }
 
-rtc_source_set("testclient") {
+rtc_library("testclient") {
   testonly = true
   sources = [
     "test_client.cc",
@@ -1016,7 +1016,7 @@
   ]
 }
 
-rtc_source_set("rtc_base_tests_utils") {
+rtc_library("rtc_base_tests_utils") {
   testonly = true
   sources = [
     "cpu_time.cc",
@@ -1067,7 +1067,7 @@
   ]
 }
 
-rtc_source_set("task_queue_for_test") {
+rtc_library("task_queue_for_test") {
   testonly = true
 
   sources = [
@@ -1088,7 +1088,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("sigslot_unittest") {
+  rtc_library("sigslot_unittest") {
     testonly = true
     sources = [
       "sigslot_unittest.cc",
@@ -1102,7 +1102,7 @@
     ]
   }
 
-  rtc_source_set("rtc_base_nonparallel_tests") {
+  rtc_library("rtc_base_nonparallel_tests") {
     testonly = true
 
     sources = [
@@ -1133,7 +1133,7 @@
     }
   }
 
-  rtc_source_set("rtc_base_approved_unittests") {
+  rtc_library("rtc_base_approved_unittests") {
     testonly = true
     sources = [
       "atomic_ops_unittest.cc",
@@ -1209,7 +1209,7 @@
     ]
   }
 
-  rtc_source_set("rtc_task_queue_unittests") {
+  rtc_library("rtc_task_queue_unittests") {
     testonly = true
 
     sources = [
@@ -1227,7 +1227,7 @@
     ]
   }
 
-  rtc_source_set("weak_ptr_unittests") {
+  rtc_library("weak_ptr_unittests") {
     testonly = true
 
     sources = [
@@ -1245,7 +1245,7 @@
     ]
   }
 
-  rtc_source_set("rtc_numerics_unittests") {
+  rtc_library("rtc_numerics_unittests") {
     testonly = true
 
     sources = [
@@ -1266,7 +1266,7 @@
     ]
   }
 
-  rtc_source_set("rtc_json_unittests") {
+  rtc_library("rtc_json_unittests") {
     testonly = true
 
     sources = [
@@ -1281,7 +1281,7 @@
     ]
   }
 
-  rtc_source_set("rtc_base_unittests") {
+  rtc_library("rtc_base_unittests") {
     testonly = true
     defines = []
 
diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn
index a167605..5b055bf 100644
--- a/rtc_base/experiments/BUILD.gn
+++ b/rtc_base/experiments/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_static_library("alr_experiment") {
+rtc_library("alr_experiment") {
   sources = [
     "alr_experiment.cc",
     "alr_experiment.h",
@@ -21,7 +21,7 @@
   ]
 }
 
-rtc_static_library("field_trial_parser") {
+rtc_library("field_trial_parser") {
   sources = [
     "field_trial_list.cc",
     "field_trial_list.h",
@@ -46,7 +46,7 @@
   ]
 }
 
-rtc_static_library("quality_scaler_settings") {
+rtc_library("quality_scaler_settings") {
   sources = [
     "quality_scaler_settings.cc",
     "quality_scaler_settings.h",
@@ -61,7 +61,7 @@
   ]
 }
 
-rtc_static_library("quality_scaling_experiment") {
+rtc_library("quality_scaling_experiment") {
   sources = [
     "quality_scaling_experiment.cc",
     "quality_scaling_experiment.h",
@@ -74,7 +74,7 @@
   ]
 }
 
-rtc_static_library("normalize_simulcast_size_experiment") {
+rtc_library("normalize_simulcast_size_experiment") {
   sources = [
     "normalize_simulcast_size_experiment.cc",
     "normalize_simulcast_size_experiment.h",
@@ -86,7 +86,7 @@
   ]
 }
 
-rtc_static_library("balanced_degradation_settings") {
+rtc_library("balanced_degradation_settings") {
   sources = [
     "balanced_degradation_settings.cc",
     "balanced_degradation_settings.h",
@@ -100,7 +100,7 @@
   ]
 }
 
-rtc_static_library("cpu_speed_experiment") {
+rtc_library("cpu_speed_experiment") {
   sources = [
     "cpu_speed_experiment.cc",
     "cpu_speed_experiment.h",
@@ -112,7 +112,7 @@
   ]
 }
 
-rtc_static_library("rtt_mult_experiment") {
+rtc_library("rtt_mult_experiment") {
   sources = [
     "rtt_mult_experiment.cc",
     "rtt_mult_experiment.h",
@@ -124,7 +124,7 @@
   ]
 }
 
-rtc_static_library("jitter_upper_bound_experiment") {
+rtc_library("jitter_upper_bound_experiment") {
   sources = [
     "jitter_upper_bound_experiment.cc",
     "jitter_upper_bound_experiment.h",
@@ -136,7 +136,7 @@
   ]
 }
 
-rtc_static_library("rate_control_settings") {
+rtc_library("rate_control_settings") {
   sources = [
     "rate_control_settings.cc",
     "rate_control_settings.h",
@@ -152,7 +152,7 @@
   ]
 }
 
-rtc_static_library("keyframe_interval_settings_experiment") {
+rtc_library("keyframe_interval_settings_experiment") {
   sources = [
     "keyframe_interval_settings.cc",
     "keyframe_interval_settings.h",
@@ -165,7 +165,7 @@
   ]
 }
 
-rtc_static_library("experimental_screenshare_settings") {
+rtc_library("experimental_screenshare_settings") {
   sources = [
     "experimental_screenshare_settings.cc",
     "experimental_screenshare_settings.h",
@@ -178,7 +178,7 @@
   ]
 }
 
-rtc_static_library("stable_target_rate_experiment") {
+rtc_library("stable_target_rate_experiment") {
   sources = [
     "stable_target_rate_experiment.cc",
     "stable_target_rate_experiment.h",
@@ -192,7 +192,7 @@
   ]
 }
 
-rtc_static_library("min_video_bitrate_experiment") {
+rtc_library("min_video_bitrate_experiment") {
   sources = [
     "min_video_bitrate_experiment.cc",
     "min_video_bitrate_experiment.h",
@@ -209,7 +209,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("experiments_unittests") {
+  rtc_library("experiments_unittests") {
     testonly = true
 
     sources = [
diff --git a/rtc_base/memory/BUILD.gn b/rtc_base/memory/BUILD.gn
index 1e3eb08..6a8c690 100644
--- a/rtc_base/memory/BUILD.gn
+++ b/rtc_base/memory/BUILD.gn
@@ -22,7 +22,7 @@
   ]
 }
 
-rtc_source_set("aligned_malloc") {
+rtc_library("aligned_malloc") {
   sources = [
     "aligned_malloc.cc",
     "aligned_malloc.h",
@@ -32,7 +32,7 @@
   ]
 }
 
-rtc_source_set("fifo_buffer") {
+rtc_library("fifo_buffer") {
   visibility = [
     "../../p2p:rtc_p2p",
     "..:rtc_base_tests_utils",
@@ -48,7 +48,7 @@
   ]
 }
 
-rtc_source_set("unittests") {
+rtc_library("unittests") {
   testonly = true
   sources = [
     "aligned_array_unittest.cc",
diff --git a/rtc_base/network/BUILD.gn b/rtc_base/network/BUILD.gn
index d396e8c..1d06def 100644
--- a/rtc_base/network/BUILD.gn
+++ b/rtc_base/network/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("sent_packet") {
+rtc_library("sent_packet") {
   sources = [
     "sent_packet.cc",
     "sent_packet.h",
diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn
index beee9b68..f860db9 100644
--- a/rtc_base/synchronization/BUILD.gn
+++ b/rtc_base/synchronization/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_source_set("rw_lock_wrapper") {
+rtc_library("rw_lock_wrapper") {
   public = [
     "rw_lock_wrapper.h",
   ]
@@ -36,7 +36,7 @@
   }
 }
 
-rtc_source_set("sequence_checker") {
+rtc_library("sequence_checker") {
   sources = [
     "sequence_checker.cc",
     "sequence_checker.h",
@@ -51,7 +51,7 @@
   ]
 }
 
-rtc_source_set("yield_policy") {
+rtc_library("yield_policy") {
   sources = [
     "yield_policy.cc",
     "yield_policy.h",
@@ -64,7 +64,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("synchronization_unittests") {
+  rtc_library("synchronization_unittests") {
     testonly = true
     sources = [
       "yield_policy_unittest.cc",
@@ -76,7 +76,7 @@
     ]
   }
 
-  rtc_source_set("sequence_checker_unittests") {
+  rtc_library("sequence_checker_unittests") {
     testonly = true
 
     sources = [
diff --git a/rtc_base/system/BUILD.gn b/rtc_base/system/BUILD.gn
index ddb0b5b..4c2b5cd 100644
--- a/rtc_base/system/BUILD.gn
+++ b/rtc_base/system/BUILD.gn
@@ -30,7 +30,7 @@
   ]
 }
 
-rtc_source_set("file_wrapper") {
+rtc_library("file_wrapper") {
   sources = [
     "file_wrapper.cc",
     "file_wrapper.h",
@@ -67,7 +67,7 @@
 }
 
 if (is_mac || is_ios) {
-  rtc_source_set("cocoa_threading") {
+  rtc_library("cocoa_threading") {
     sources = [
       "cocoa_threading.h",
       "cocoa_threading.mm",
diff --git a/rtc_base/task_utils/BUILD.gn b/rtc_base/task_utils/BUILD.gn
index 7eca496..8d8a458 100644
--- a/rtc_base/task_utils/BUILD.gn
+++ b/rtc_base/task_utils/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("repeating_task") {
+rtc_library("repeating_task") {
   sources = [
     "repeating_task.cc",
     "repeating_task.h",
@@ -36,7 +36,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("repeating_task_unittests") {
+  rtc_library("repeating_task_unittests") {
     testonly = true
     sources = [
       "repeating_task_unittest.cc",
@@ -50,7 +50,7 @@
     ]
   }
 
-  rtc_source_set("to_queued_task_unittests") {
+  rtc_library("to_queued_task_unittests") {
     testonly = true
     sources = [
       "to_queued_task_unittest.cc",
diff --git a/rtc_base/third_party/base64/BUILD.gn b/rtc_base/third_party/base64/BUILD.gn
index 022f509..3abd0cb 100644
--- a/rtc_base/third_party/base64/BUILD.gn
+++ b/rtc_base/third_party/base64/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("base64") {
+rtc_library("base64") {
   visibility = [ "*" ]
   sources = [
     "base64.cc",
diff --git a/rtc_base/third_party/sigslot/BUILD.gn b/rtc_base/third_party/sigslot/BUILD.gn
index aea748e..186a05c 100644
--- a/rtc_base/third_party/sigslot/BUILD.gn
+++ b/rtc_base/third_party/sigslot/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("sigslot") {
+rtc_library("sigslot") {
   visibility = [ "*" ]
   sources = [
     "sigslot.cc",
diff --git a/rtc_base/time/BUILD.gn b/rtc_base/time/BUILD.gn
index 7b298ce..2bf90f2 100644
--- a/rtc_base/time/BUILD.gn
+++ b/rtc_base/time/BUILD.gn
@@ -12,7 +12,7 @@
   import("//build/config/android/rules.gni")
 }
 
-rtc_source_set("timestamp_extrapolator") {
+rtc_library("timestamp_extrapolator") {
   sources = [
     "timestamp_extrapolator.cc",
     "timestamp_extrapolator.h",
diff --git a/rtc_base/units/BUILD.gn b/rtc_base/units/BUILD.gn
index 8c722bbc..7282ef6 100644
--- a/rtc_base/units/BUILD.gn
+++ b/rtc_base/units/BUILD.gn
@@ -24,7 +24,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("units_unittests") {
+  rtc_library("units_unittests") {
     testonly = true
     sources = [
       "unit_base_unittest.cc",
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index 8d09587..3e73f3a 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -44,7 +44,7 @@
   }
 }
 
-rtc_static_library("video_file_reader") {
+rtc_library("video_file_reader") {
   sources = [
     "video_file_reader.cc",
     "video_file_reader.h",
@@ -61,7 +61,7 @@
   ]
 }
 
-rtc_static_library("video_file_writer") {
+rtc_library("video_file_writer") {
   sources = [
     "video_file_writer.cc",
     "video_file_writer.h",
@@ -78,7 +78,7 @@
   ]
 }
 
-rtc_static_library("video_quality_analysis") {
+rtc_library("video_quality_analysis") {
   sources = [
     "frame_analyzer/linear_least_squares.cc",
     "frame_analyzer/linear_least_squares.h",
@@ -204,7 +204,7 @@
     ]
   }
 
-  rtc_static_library("reference_less_video_analysis_lib") {
+  rtc_library("reference_less_video_analysis_lib") {
     sources = [
       "frame_analyzer/reference_less_video_analysis_lib.cc",
       "frame_analyzer/reference_less_video_analysis_lib.h",
@@ -261,7 +261,7 @@
       proto_out_dir = "rtc_tools/rtc_event_log_visualizer/proto"
     }
 
-    rtc_static_library("event_log_visualizer_utils") {
+    rtc_library("event_log_visualizer_utils") {
       visibility = [ "*" ]
       sources = [
         "rtc_event_log_visualizer/analyzer.cc",
diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn
index 0d2c043..2851666 100644
--- a/rtc_tools/network_tester/BUILD.gn
+++ b/rtc_tools/network_tester/BUILD.gn
@@ -26,7 +26,7 @@
     proto_out_dir = "rtc_tools/network_tester"
   }
 
-  rtc_static_library("network_tester") {
+  rtc_library("network_tester") {
     sources = [
       "config_reader.cc",
       "config_reader.h",
@@ -72,7 +72,7 @@
     }
   }
 
-  rtc_source_set("network_tester_unittests") {
+  rtc_library("network_tester_unittests") {
     testonly = true
 
     sources = [
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 2c8a114..08b30d1 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -27,7 +27,7 @@
   }
 }
 
-rtc_source_set("media_constraints") {
+rtc_library("media_constraints") {
   sources = [
     "media_constraints.cc",
     "media_constraints.h",
@@ -39,7 +39,7 @@
   ]
 }
 
-rtc_source_set("sdk_tests") {
+rtc_library("sdk_tests") {
   testonly = true
   sources = [
     "media_constraints_unittest.cc",
@@ -81,7 +81,7 @@
 
   # TODO(bugs.webrtc.org/9627): Remove this when unused. Targets should depend on base_objc
   # or helpers_objc directly instead.
-  rtc_static_library("common_objc") {
+  rtc_library("common_objc") {
     visibility = [ "*" ]
 
     sources = [
@@ -96,7 +96,7 @@
     ]
   }
 
-  rtc_static_library("base_objc") {
+  rtc_library("base_objc") {
     visibility = [ "*" ]
     sources = [
       "objc/base/RTCCodecSpecificInfo.h",
@@ -141,7 +141,7 @@
     public_configs = [ ":common_config_objc" ]
   }
 
-  rtc_static_library("helpers_objc") {
+  rtc_library("helpers_objc") {
     sources = [
       "objc/helpers/AVCaptureSession+DevicePosition.h",
       "objc/helpers/AVCaptureSession+DevicePosition.mm",
@@ -181,7 +181,7 @@
   }
 
   if (!build_with_chromium) {
-    rtc_static_library("callback_logger_objc") {
+    rtc_library("callback_logger_objc") {
       sources = [
         "objc/api/logging/RTCCallbackLogger.h",
         "objc/api/logging/RTCCallbackLogger.mm",
@@ -200,7 +200,7 @@
       ]
     }
 
-    rtc_static_library("file_logger_objc") {
+    rtc_library("file_logger_objc") {
       sources = [
         "objc/api/peerconnection/RTCFileLogger.h",
         "objc/api/peerconnection/RTCFileLogger.mm",
@@ -222,7 +222,7 @@
 
   if (!build_with_chromium) {
     if (is_ios) {
-      rtc_static_library("native_api_audio_device_module") {
+      rtc_library("native_api_audio_device_module") {
         visibility = [ "*" ]
 
         sources = [
@@ -252,7 +252,7 @@
         ]
       }
 
-      rtc_static_library("audio_device") {
+      rtc_library("audio_device") {
         visibility = [ "*" ]
 
         sources = [
@@ -286,7 +286,7 @@
         libs = [ "AudioToolbox.framework" ]
       }
 
-      rtc_static_library("audio_objc") {
+      rtc_library("audio_objc") {
         sources = [
           "objc/components/audio/RTCAudioSession+Configuration.mm",
           "objc/components/audio/RTCAudioSession+Private.h",
@@ -317,7 +317,7 @@
       }
     }
 
-    rtc_static_library("videosource_objc") {
+    rtc_library("videosource_objc") {
       sources = [
         "objc/api/peerconnection/RTCVideoSource+Private.h",
         "objc/api/peerconnection/RTCVideoSource.h",
@@ -347,7 +347,7 @@
       ]
     }
 
-    rtc_static_library("videoframebuffer_objc") {
+    rtc_library("videoframebuffer_objc") {
       visibility = [ "*" ]
       sources = [
         "objc/api/video_frame_buffer/RTCNativeI420Buffer+Private.h",
@@ -379,7 +379,7 @@
       ]
     }
 
-    rtc_static_library("video_objc") {
+    rtc_library("video_objc") {
       sources = [
         "objc/components/renderer/opengl/RTCDefaultShader.h",
         "objc/components/renderer/opengl/RTCDefaultShader.mm",
@@ -431,7 +431,7 @@
       ]
     }
 
-    rtc_static_library("ui_objc") {
+    rtc_library("ui_objc") {
       visibility = [ "*" ]
       allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
       if (is_ios) {
@@ -459,7 +459,7 @@
     }
 
     if (rtc_use_metal_rendering) {
-      rtc_static_library("metal_objc") {
+      rtc_library("metal_objc") {
         visibility = [ "*" ]
         allow_poison = [
           "audio_codecs",  # TODO(bugs.webrtc.org/8396): Remove.
@@ -510,7 +510,7 @@
     }
 
     # TODO(bugs.webrtc.org/9627): Remove this target.
-    rtc_static_library("videocapturebase_objc") {
+    rtc_library("videocapturebase_objc") {
       visibility = [ "*" ]
       sources = [
         "objc/helpers/noop.mm",
@@ -526,7 +526,7 @@
       ]
     }
 
-    rtc_static_library("videocapture_objc") {
+    rtc_library("videocapture_objc") {
       visibility = [ "*" ]
       allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
       sources = [
@@ -556,7 +556,7 @@
       ]
     }
 
-    rtc_static_library("videocodec_objc") {
+    rtc_library("videocodec_objc") {
       visibility = [ "*" ]
       configs += [ "..:no_global_constructors" ]
       sources = [
@@ -588,7 +588,7 @@
       ]
     }
 
-    rtc_static_library("default_codec_factory_objc") {
+    rtc_library("default_codec_factory_objc") {
       sources = [
         "objc/components/video_codec/RTCDefaultVideoDecoderFactory.h",
         "objc/components/video_codec/RTCDefaultVideoDecoderFactory.m",
@@ -607,7 +607,7 @@
       ]
     }
 
-    rtc_static_library("vpx_codec_constants") {
+    rtc_library("vpx_codec_constants") {
       configs += [ "..:no_global_constructors" ]
       sources = [
         "objc/api/video_codec/RTCVideoCodecConstants.h",
@@ -620,7 +620,7 @@
       ]
     }
 
-    rtc_static_library("vp8") {
+    rtc_library("vp8") {
       visibility = [ "*" ]
       allow_poison = [ "software_video_codecs" ]
       sources = [
@@ -637,7 +637,7 @@
       ]
     }
 
-    rtc_static_library("vp9") {
+    rtc_library("vp9") {
       visibility = [ "*" ]
       allow_poison = [ "software_video_codecs" ]
       sources = [
@@ -662,7 +662,7 @@
     # when implementing webrtc::PeerConnectionFactoryInterface and
     # webrtc::PeerConnectionInterface.
     # The applications which only use WebRTC DataChannel can depend on this.
-    rtc_static_library("peerconnectionfactory_no_media_objc") {
+    rtc_library("peerconnectionfactory_no_media_objc") {
       visibility = [ "*" ]
       allow_poison = [
         "audio_codecs",  # TODO(bugs.webrtc.org/8396): Remove.
@@ -685,7 +685,7 @@
       ]
     }
 
-    rtc_static_library("mediaconstraints_objc") {
+    rtc_library("mediaconstraints_objc") {
       configs += [ "..:no_global_constructors" ]
       sources = [
         "objc/api/peerconnection/RTCMediaConstraints+Private.h",
@@ -702,7 +702,7 @@
     }
 
     # TODO(bugs.webrtc.org/9627): Remove, targets should depend on base_objc.
-    rtc_source_set("videorenderer_objc") {
+    rtc_library("videorenderer_objc") {
       visibility = [ "*" ]
       sources = [
         "objc/helpers/noop.mm",
@@ -716,7 +716,7 @@
       ]
     }
 
-    rtc_static_library("videorendereradapter_objc") {
+    rtc_library("videorendereradapter_objc") {
       visibility = [ "*" ]
       allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
       sources = [
@@ -737,7 +737,7 @@
       ]
     }
 
-    rtc_static_library("mediasource_objc") {
+    rtc_library("mediasource_objc") {
       sources = [
         "objc/api/peerconnection/RTCMediaSource+Private.h",
         "objc/api/peerconnection/RTCMediaSource.h",
@@ -757,7 +757,7 @@
       ]
     }
 
-    rtc_static_library("base_native_additions_objc") {
+    rtc_library("base_native_additions_objc") {
       sources = [
         "objc/api/peerconnection/RTCEncodedImage+Private.h",
         "objc/api/peerconnection/RTCEncodedImage+Private.mm",
@@ -784,7 +784,7 @@
       ]
     }
 
-    rtc_static_library("peerconnectionfactory_base_objc") {
+    rtc_library("peerconnectionfactory_base_objc") {
       visibility = [ "*" ]
       allow_poison = [
         "audio_codecs",  # TODO(bugs.webrtc.org/8396): Remove.
@@ -1045,7 +1045,7 @@
 
     if (rtc_include_tests) {
       if (is_ios) {
-        rtc_source_set("sdk_unittests_sources") {
+        rtc_library("sdk_unittests_sources") {
           testonly = true
           include_dirs = [ "objc/" ]
 
@@ -1164,7 +1164,7 @@
       }
 
       # TODO(denicija): once all tests are migrated to xctest remove this source set.
-      rtc_source_set("rtc_unittests_objc") {
+      rtc_library("rtc_unittests_objc") {
         testonly = true
 
         sources = [
@@ -1523,7 +1523,7 @@
       }
     }
 
-    rtc_static_library("wrapped_native_codec_objc") {
+    rtc_library("wrapped_native_codec_objc") {
       sources = [
         "objc/api/video_codec/RTCWrappedNativeVideoDecoder.h",
         "objc/api/video_codec/RTCWrappedNativeVideoDecoder.mm",
@@ -1543,7 +1543,7 @@
     }
 
     # The native API is currently experimental and may change without notice.
-    rtc_static_library("native_api") {
+    rtc_library("native_api") {
       visibility = [ "*" ]
       allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
       sources = [
@@ -1581,7 +1581,7 @@
       ]
     }
 
-    rtc_static_library("native_video") {
+    rtc_library("native_video") {
       sources = [
         "objc/native/src/objc_frame_buffer.h",
         "objc/native/src/objc_frame_buffer.mm",
@@ -1623,7 +1623,7 @@
       ]
     }
 
-    rtc_static_library("video_toolbox_cc") {
+    rtc_library("video_toolbox_cc") {
       visibility = [
         ":videotoolbox_objc",
         ":sdk_unittests_sources",
@@ -1643,7 +1643,7 @@
       ]
     }
 
-    rtc_static_library("videotoolbox_objc") {
+    rtc_library("videotoolbox_objc") {
       visibility = [ "*" ]
       allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
       sources = [
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index f6fd462..4a805f8 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -104,7 +104,7 @@
     ]
   }
 
-  rtc_static_library("libjingle_peerconnection_jni") {
+  rtc_library("libjingle_peerconnection_jni") {
     visibility = [ "*" ]
     allow_poison = [
       "audio_codecs",  # TODO(bugs.webrtc.org/8396): Remove.
@@ -123,7 +123,7 @@
     ]
   }
 
-  rtc_static_library("libjingle_peerconnection_metrics_default_jni") {
+  rtc_library("libjingle_peerconnection_metrics_default_jni") {
     visibility = [ "*" ]
     sources = [
       "src/jni/android_metrics.cc",
@@ -530,7 +530,7 @@
 
   # Mirrors the order of targets in the section above.
 
-  rtc_source_set("base_jni") {
+  rtc_library("base_jni") {
     visibility = [ "*" ]
     sources = [
       "src/jni/android_histogram.cc",
@@ -562,7 +562,7 @@
     ]
   }
 
-  rtc_static_library("audio_jni") {
+  rtc_library("audio_jni") {
     visibility = [ "*" ]
     allow_poison = [ "audio_codecs" ]
     sources = [
@@ -580,7 +580,7 @@
     ]
   }
 
-  rtc_static_library("builtin_audio_codecs_jni") {
+  rtc_library("builtin_audio_codecs_jni") {
     visibility = [ "*" ]
     allow_poison = [ "audio_codecs" ]
     sources = [
@@ -599,7 +599,7 @@
   }
 
   # Corresponds to MediaCodecVideoEncoder/Decoder in Java.
-  rtc_static_library("legacy_hwcodecs_jni") {
+  rtc_library("legacy_hwcodecs_jni") {
     visibility = [ "*" ]
     allow_poison = [ "software_video_codecs" ]
     sources = [
@@ -633,7 +633,7 @@
     ]
   }
 
-  rtc_static_library("video_jni") {
+  rtc_library("video_jni") {
     visibility = [ "*" ]
     sources = [
       "src/jni/android_video_track_source.cc",
@@ -697,7 +697,7 @@
     ]
   }
 
-  rtc_static_library("peerconnection_jni") {
+  rtc_library("peerconnection_jni") {
     # Do not depend on this target externally unless you absolute have to. It is
     # made public because we don't have a proper NDK yet. Header APIs here are not
     # considered public and are subject to change.
@@ -788,7 +788,7 @@
   }
 
   # JNI target for java_audio_device_module_java
-  rtc_source_set("java_audio_device_module_jni") {
+  rtc_library("java_audio_device_module_jni") {
     visibility = [ "*" ]
     sources = [
       "src/jni/audio_device/java_audio_device_module.cc",
@@ -801,7 +801,7 @@
     ]
   }
 
-  rtc_static_library("default_video_codec_factory_jni") {
+  rtc_library("default_video_codec_factory_jni") {
     visibility = [ "*" ]
     allow_poison = [ "software_video_codecs" ]
     deps = [
@@ -810,7 +810,7 @@
     ]
   }
 
-  rtc_static_library("libvpx_vp8_jni") {
+  rtc_library("libvpx_vp8_jni") {
     visibility = [ "*" ]
     allow_poison = [ "software_video_codecs" ]
     sources = [
@@ -824,7 +824,7 @@
     ]
   }
 
-  rtc_static_library("libvpx_vp9_jni") {
+  rtc_library("libvpx_vp9_jni") {
     visibility = [ "*" ]
     allow_poison = [ "software_video_codecs" ]
     sources = [
@@ -838,7 +838,7 @@
     ]
   }
 
-  rtc_static_library("swcodecs_jni") {
+  rtc_library("swcodecs_jni") {
     visibility = [ "*" ]
     allow_poison = [ "software_video_codecs" ]
     deps = [
@@ -855,7 +855,7 @@
 
   # JNI helpers that are also needed from internal JNI code. Cannot depend on any
   # other JNI targets than internal_jni.
-  rtc_static_library("native_api_jni") {
+  rtc_library("native_api_jni") {
     visibility = [ "*" ]
     sources = [
       "native_api/jni/class_loader.cc",
@@ -884,7 +884,7 @@
     ]
   }
 
-  rtc_static_library("native_api_base") {
+  rtc_library("native_api_base") {
     visibility = [ "*" ]
     sources = [
       "native_api/base/init.cc",
@@ -903,7 +903,7 @@
 
   # Modules, in alphabetical order.
 
-  rtc_source_set("native_api_audio_device_module") {
+  rtc_library("native_api_audio_device_module") {
     visibility = [ "*" ]
 
     sources = [
@@ -929,7 +929,7 @@
 
   # API for wrapping Java VideoDecoderFactory/VideoEncoderFactory classes to C++
   # objects.
-  rtc_static_library("native_api_codecs") {
+  rtc_library("native_api_codecs") {
     visibility = [ "*" ]
     allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
     sources = [
@@ -948,7 +948,7 @@
   }
 
   # API for creating Java PeerConnectionFactory from C++ equivalents.
-  rtc_static_library("native_api_peerconnection") {
+  rtc_library("native_api_peerconnection") {
     visibility = [ "*" ]
     sources = [
       "native_api/peerconnection/peer_connection_factory.cc",
@@ -964,7 +964,7 @@
   }
 
   # API for capturing and printing native stacktraces.
-  rtc_static_library("native_api_stacktrace") {
+  rtc_library("native_api_stacktrace") {
     visibility = [ "*" ]
     sources = [
       "native_api/stacktrace/stacktrace.cc",
@@ -981,7 +981,7 @@
 
   # API for creating C++ wrapper implementations of api/mediastreaminterface.h
   # video interfaces from their Java equivalents.
-  rtc_static_library("native_api_video") {
+  rtc_library("native_api_video") {
     visibility = [ "*" ]
     allow_poison = [ "audio_codecs" ]  # TODO(bugs.webrtc.org/8396): Remove.
     sources = [
@@ -1019,7 +1019,7 @@
   # Internal code that is needed by native_api_jni. The code cannot be placed in
   # base_jni because native_api_jni depends on the code (and base_jni depends on
   # native_api_jni).
-  rtc_source_set("internal_jni") {
+  rtc_library("internal_jni") {
     sources = [
       "src/jni/jvm.cc",
       "src/jni/jvm.h",
@@ -1030,7 +1030,7 @@
     ]
   }
 
-  rtc_static_library("videoframe_jni") {
+  rtc_library("videoframe_jni") {
     sources = [
       "src/jni/video_frame.cc",
       "src/jni/video_frame.h",
@@ -1052,7 +1052,7 @@
     ]
   }
 
-  rtc_static_library("logging_jni") {
+  rtc_library("logging_jni") {
     visibility = [ "*" ]
     sources = [
       "src/jni/logging/log_sink.cc",
@@ -1067,7 +1067,7 @@
     ]
   }
 
-  rtc_source_set("audio_device_module_base") {
+  rtc_library("audio_device_module_base") {
     visibility = [ "*" ]
 
     sources = [
@@ -1091,7 +1091,7 @@
     ]
   }
 
-  rtc_source_set("java_audio_device_module") {
+  rtc_library("java_audio_device_module") {
     visibility = [ "*" ]
 
     sources = [
@@ -1115,7 +1115,7 @@
   }
 
   if (rtc_enable_android_aaudio) {
-    rtc_source_set("aaudio_audio_device_module") {
+    rtc_library("aaudio_audio_device_module") {
       visibility = [ "*" ]
       defines = [ "WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO" ]
       sources = [
@@ -1142,7 +1142,7 @@
     }
   }
 
-  rtc_source_set("opensles_audio_device_module") {
+  rtc_library("opensles_audio_device_module") {
     visibility = [ "*" ]
     sources = [
       "src/jni/audio_device/opensles_common.cc",
@@ -1436,7 +1436,7 @@
     output_extension = "so"
   }
 
-  rtc_static_library("instrumentationtests_jni") {
+  rtc_library("instrumentationtests_jni") {
     testonly = true
     sources = [
       "instrumentationtests/loggable_test.cc",
@@ -1449,7 +1449,7 @@
     ]
   }
 
-  rtc_source_set("native_unittests") {
+  rtc_library("native_unittests") {
     testonly = true
 
     sources = [
diff --git a/stats/BUILD.gn b/stats/BUILD.gn
index b3a9d9e..7d5f710 100644
--- a/stats/BUILD.gn
+++ b/stats/BUILD.gn
@@ -14,7 +14,7 @@
   ]
 }
 
-rtc_static_library("rtc_stats") {
+rtc_library("rtc_stats") {
   visibility = [ "*" ]
   cflags = []
   sources = [
@@ -30,7 +30,7 @@
   ]
 }
 
-rtc_source_set("rtc_stats_test_utils") {
+rtc_library("rtc_stats_test_utils") {
   visibility = [ "*" ]
   cflags = []
   sources = [
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index 8730098..f80b08e 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -12,7 +12,7 @@
 }
 import("../webrtc.gni")
 
-rtc_static_library("system_wrappers") {
+rtc_library("system_wrappers") {
   visibility = [ "*" ]
   sources = [
     "include/clock.h",
@@ -82,7 +82,7 @@
   ]
 }
 
-rtc_source_set("field_trial") {
+rtc_library("field_trial") {
   visibility = [ "*" ]
   public = [
     "include/field_trial.h",
@@ -108,7 +108,7 @@
   }
 }
 
-rtc_source_set("event_wrapper") {
+rtc_library("event_wrapper") {
   visibility = [
     "../modules/video_coding:video_coding_legacy",
     "../modules/video_coding:video_coding_unittests",
@@ -122,7 +122,7 @@
   ]
 }
 
-rtc_source_set("metrics") {
+rtc_library("metrics") {
   visibility = [ "*" ]
   public = [
     "include/metrics.h",
@@ -143,7 +143,7 @@
 }
 
 if (is_android && !build_with_mozilla) {
-  rtc_static_library("cpu_features_android") {
+  rtc_library("cpu_features_android") {
     sources = [
       "source/cpu_features_android.c",
     ]
@@ -155,7 +155,7 @@
 }
 
 if (is_linux) {
-  rtc_static_library("cpu_features_linux") {
+  rtc_library("cpu_features_linux") {
     sources = [
       "source/cpu_features_linux.c",
     ]
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 401ffcf..9d3c9ae 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -34,7 +34,7 @@
   }
 }
 
-rtc_source_set("video_test_common") {
+rtc_library("video_test_common") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -74,7 +74,7 @@
 
 if (!build_with_chromium) {
   if (is_mac || is_ios) {
-    rtc_source_set("video_test_mac") {
+    rtc_library("video_test_mac") {
       testonly = true
       sources = [
         "mac_capturer.h",
@@ -95,7 +95,7 @@
     }
   }
 
-  rtc_source_set("platform_video_capturer") {
+  rtc_library("platform_video_capturer") {
     testonly = true
     sources = [
       "platform_video_capturer.cc",
@@ -122,7 +122,7 @@
   }
 }
 
-rtc_source_set("rtp_test_utils") {
+rtc_library("rtp_test_utils") {
   testonly = true
   sources = [
     "rtcp_packet_parser.cc",
@@ -146,7 +146,7 @@
   ]
 }
 
-rtc_source_set("field_trial") {
+rtc_library("field_trial") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -159,7 +159,7 @@
   ]
 }
 
-rtc_source_set("perf_test") {
+rtc_library("perf_test") {
   visibility = [ "*" ]
   sources = [
     "testsupport/perf_test.cc",
@@ -174,7 +174,7 @@
 }
 
 if (is_ios) {
-  rtc_source_set("test_support_objc") {
+  rtc_library("test_support_objc") {
     testonly = true
     visibility = [ ":test_support" ]
     sources = [
@@ -243,7 +243,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("test_main_lib") {
+  rtc_library("test_main_lib") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -267,7 +267,7 @@
     ]
   }
 
-  rtc_source_set("test_main") {
+  rtc_library("test_main") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -281,7 +281,7 @@
     ]
   }
 
-  rtc_source_set("video_test_support") {
+  rtc_library("video_test_support") {
     testonly = true
 
     sources = [
@@ -323,7 +323,7 @@
     }
   }
 
-  rtc_source_set("test_support_test_artifacts") {
+  rtc_library("test_support_test_artifacts") {
     testonly = true
     sources = [
       "testsupport/test_artifacts.cc",
@@ -436,7 +436,7 @@
 }
 
 if (is_ios) {
-  rtc_source_set("fileutils_ios_objc") {
+  rtc_library("fileutils_ios_objc") {
     visibility = [
       ":fileutils",
       ":fileutils_override_impl",
@@ -454,7 +454,7 @@
 }
 
 if (is_mac) {
-  rtc_source_set("fileutils_mac_objc") {
+  rtc_library("fileutils_mac_objc") {
     visibility = [
       ":fileutils",
       ":fileutils_override_impl",
@@ -469,7 +469,7 @@
   }
 }
 
-rtc_source_set("fileutils") {
+rtc_library("fileutils") {
   testonly = true
   visibility = [ "*" ]
   sources = [
@@ -495,7 +495,7 @@
   }
 }
 
-rtc_source_set("resources_dir_flag") {
+rtc_library("resources_dir_flag") {
   testonly = true
   visibility = [ "*" ]
   sources = [
@@ -516,7 +516,7 @@
   ]
 }
 
-rtc_source_set("fileutils_override_impl") {
+rtc_library("fileutils_override_impl") {
   testonly = true
   visibility = [ ":fileutils" ]
   sources = [
@@ -560,7 +560,7 @@
 }
 
 if (is_mac) {
-  rtc_source_set("run_test_objc") {
+  rtc_library("run_test_objc") {
     testonly = true
     visibility = [ ":run_test" ]
     sources = [
@@ -572,7 +572,7 @@
   }
 }
 
-rtc_source_set("run_test_generic") {
+rtc_library("run_test_generic") {
   testonly = true
   visibility = [ ":run_test" ]
   sources = [
@@ -583,7 +583,7 @@
   ]
 }
 
-rtc_source_set("fileutils_unittests") {
+rtc_library("fileutils_unittests") {
   testonly = true
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
   sources = [
@@ -599,7 +599,7 @@
   ]
 }
 
-rtc_source_set("direct_transport") {
+rtc_library("direct_transport") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -627,7 +627,7 @@
   ]
 }
 
-rtc_source_set("single_threaded_task_queue") {
+rtc_library("single_threaded_task_queue") {
   testonly = true
   sources = [
     "single_threaded_task_queue.cc",
@@ -643,7 +643,7 @@
   ]
 }
 
-rtc_source_set("fake_video_codecs") {
+rtc_library("fake_video_codecs") {
   allow_poison = [ "software_video_codecs" ]
   visibility = [ "*" ]
   sources = [
@@ -685,7 +685,7 @@
   ]
 }
 
-rtc_source_set("null_transport") {
+rtc_library("null_transport") {
   testonly = true
   sources = [
     "null_transport.cc",
@@ -696,7 +696,7 @@
   ]
 }
 
-rtc_source_set("encoder_settings") {
+rtc_library("encoder_settings") {
   testonly = true
   sources = [
     "encoder_settings.cc",
@@ -712,7 +712,7 @@
   ]
 }
 
-rtc_source_set("test_common") {
+rtc_library("test_common") {
   testonly = true
   sources = [
     "call_test.cc",
@@ -816,7 +816,7 @@
 }
 
 if (is_mac) {
-  rtc_source_set("test_renderer_objc") {
+  rtc_library("test_renderer_objc") {
     testonly = true
     visibility = [ ":test_renderer" ]
     sources = [
@@ -835,7 +835,7 @@
   }
 }
 
-rtc_source_set("test_renderer_generic") {
+rtc_library("test_renderer_generic") {
   testonly = true
   visibility = [
     ":test_renderer",
@@ -889,7 +889,7 @@
   }
 }
 
-rtc_source_set("audio_codec_mocks") {
+rtc_library("audio_codec_mocks") {
   testonly = true
   sources = [
     # TODO(nisse): Move these factories to their own target, to avoid
@@ -916,7 +916,7 @@
   ]
 }
 
-rtc_source_set("copy_to_file_audio_capturer") {
+rtc_library("copy_to_file_audio_capturer") {
   testonly = true
   sources = [
     "testsupport/copy_to_file_audio_capturer.cc",
@@ -931,7 +931,7 @@
   ]
 }
 
-rtc_source_set("copy_to_file_audio_capturer_unittest") {
+rtc_library("copy_to_file_audio_capturer_unittest") {
   testonly = true
   sources = [
     "testsupport/copy_to_file_audio_capturer_unittest.cc",
@@ -958,7 +958,7 @@
   }
 }
 
-rtc_source_set("call_config_utils") {
+rtc_library("call_config_utils") {
   # TODO(bugs.webrtc.org/10814): Remove rtc_json_suppressions as soon as it
   # gets removed upstream.
   public_configs = [ "../rtc_base:rtc_json_suppressions" ]
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index 2768ad4..d6dbf51 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -10,7 +10,7 @@
 import("//testing/libfuzzer/fuzzer_test.gni")
 import("../../webrtc.gni")
 
-rtc_static_library("webrtc_fuzzer_main") {
+rtc_library("webrtc_fuzzer_main") {
   sources = [
     "webrtc_fuzzer_main.cc",
   ]
@@ -29,7 +29,7 @@
   }
 }
 
-rtc_static_library("fuzz_data_helper") {
+rtc_library("fuzz_data_helper") {
   sources = [
     "fuzz_data_helper.cc",
     "fuzz_data_helper.h",
@@ -262,7 +262,7 @@
   ]
 }
 
-rtc_static_library("audio_decoder_fuzzer") {
+rtc_library("audio_decoder_fuzzer") {
   sources = [
     "audio_decoder_fuzzer.cc",
     "audio_decoder_fuzzer.h",
@@ -468,7 +468,7 @@
     "../../rtc_base:rtc_base_approved",
   ]
 }
-rtc_static_library("audio_processing_fuzzer_helper") {
+rtc_library("audio_processing_fuzzer_helper") {
   sources = [
     "audio_processing_fuzzer_helper.cc",
     "audio_processing_fuzzer_helper.h",
diff --git a/test/fuzzers/utils/BUILD.gn b/test/fuzzers/utils/BUILD.gn
index 61f7a80..8436dc0 100644
--- a/test/fuzzers/utils/BUILD.gn
+++ b/test/fuzzers/utils/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../../webrtc.gni")
 
-rtc_source_set("rtp_replayer") {
+rtc_library("rtp_replayer") {
   testonly = true
   sources = [
     "rtp_replayer.cc",
diff --git a/test/logging/BUILD.gn b/test/logging/BUILD.gn
index ee00d1c..db2a544 100644
--- a/test/logging/BUILD.gn
+++ b/test/logging/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("log_writer") {
+rtc_library("log_writer") {
   testonly = true
   visibility = [ "*" ]
   sources = [
diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn
index ea6c386..c1ad2a5 100644
--- a/test/network/BUILD.gn
+++ b/test/network/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("emulated_network") {
+rtc_library("emulated_network") {
   visibility = [
     "../../api:create_network_emulation_manager",
     ":*",
@@ -62,7 +62,7 @@
   ]
 }
 
-rtc_source_set("network_emulation_unittest") {
+rtc_library("network_emulation_unittest") {
   testonly = true
   sources = [
     "network_emulation_unittest.cc",
@@ -80,7 +80,7 @@
   ]
 }
 
-rtc_source_set("network_emulation_pc_unittest") {
+rtc_library("network_emulation_pc_unittest") {
   testonly = true
   sources = [
     "network_emulation_pc_unittest.cc",
@@ -108,7 +108,7 @@
   ]
 }
 
-rtc_source_set("cross_traffic_unittest") {
+rtc_library("cross_traffic_unittest") {
   testonly = true
   sources = [
     "cross_traffic_unittest.cc",
@@ -124,7 +124,7 @@
   ]
 }
 
-rtc_source_set("feedback_generator") {
+rtc_library("feedback_generator") {
   testonly = true
   sources = [
     "feedback_generator.cc",
@@ -140,7 +140,7 @@
   ]
 }
 
-rtc_source_set("feedback_generator_unittest") {
+rtc_library("feedback_generator_unittest") {
   testonly = true
   sources = [
     "feedback_generator_unittest.cc",
@@ -151,7 +151,7 @@
   ]
 }
 
-rtc_source_set("network_emulation_unittests") {
+rtc_library("network_emulation_unittests") {
   testonly = true
   deps = [
     ":cross_traffic_unittest",
diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn
index 5ab0f68..5a99442 100644
--- a/test/pc/e2e/BUILD.gn
+++ b/test/pc/e2e/BUILD.gn
@@ -41,7 +41,7 @@
   }
 }
 
-rtc_source_set("peer_connection_quality_test_params") {
+rtc_library("peer_connection_quality_test_params") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -63,7 +63,7 @@
   ]
 }
 
-rtc_source_set("encoded_image_data_injector_api") {
+rtc_library("encoded_image_data_injector_api") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -75,7 +75,7 @@
   ]
 }
 
-rtc_source_set("default_encoded_image_data_injector") {
+rtc_library("default_encoded_image_data_injector") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -92,7 +92,7 @@
   ]
 }
 
-rtc_source_set("single_process_encoded_image_data_injector") {
+rtc_library("single_process_encoded_image_data_injector") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -109,7 +109,7 @@
   ]
 }
 
-rtc_source_set("id_generator") {
+rtc_library("id_generator") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -119,7 +119,7 @@
   deps = []
 }
 
-rtc_source_set("simulcast_dummy_buffer_helper") {
+rtc_library("simulcast_dummy_buffer_helper") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -132,7 +132,7 @@
   ]
 }
 
-rtc_source_set("quality_analyzing_video_decoder") {
+rtc_library("quality_analyzing_video_decoder") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -156,7 +156,7 @@
   ]
 }
 
-rtc_source_set("quality_analyzing_video_encoder") {
+rtc_library("quality_analyzing_video_encoder") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -178,7 +178,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("video_quality_analyzer_injection_helper") {
+  rtc_library("video_quality_analyzer_injection_helper") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -204,7 +204,7 @@
     ]
   }
 
-  rtc_source_set("echo_emulation") {
+  rtc_library("echo_emulation") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -218,7 +218,7 @@
     ]
   }
 
-  rtc_source_set("test_peer") {
+  rtc_library("test_peer") {
     visibility = [ "*" ]
     testonly = true
     sources = [
@@ -256,7 +256,7 @@
     ]
   }
 
-  rtc_source_set("peerconnection_quality_test") {
+  rtc_library("peerconnection_quality_test") {
     visibility = [ "*" ]
     testonly = true
 
@@ -305,7 +305,7 @@
     ]
   }
 
-  rtc_source_set("single_process_encoded_image_data_injector_unittest") {
+  rtc_library("single_process_encoded_image_data_injector_unittest") {
     testonly = true
     sources = [
       "analyzer/video/single_process_encoded_image_data_injector_unittest.cc",
@@ -318,7 +318,7 @@
     ]
   }
 
-  rtc_source_set("default_encoded_image_data_injector_unittest") {
+  rtc_library("default_encoded_image_data_injector_unittest") {
     testonly = true
     sources = [
       "analyzer/video/default_encoded_image_data_injector_unittest.cc",
@@ -345,7 +345,7 @@
     }
   }
 
-  rtc_source_set("peer_connection_e2e_smoke_test") {
+  rtc_library("peer_connection_e2e_smoke_test") {
     testonly = true
 
     sources = [
@@ -388,7 +388,7 @@
     }
   }
 
-  rtc_source_set("stats_poller") {
+  rtc_library("stats_poller") {
     testonly = true
     sources = [
       "stats_poller.cc",
@@ -403,7 +403,7 @@
   }
 }
 
-rtc_source_set("analyzer_helper") {
+rtc_library("analyzer_helper") {
   visibility = [ "*" ]
   sources = [
     "analyzer_helper.cc",
@@ -416,7 +416,7 @@
   ]
 }
 
-rtc_source_set("default_audio_quality_analyzer") {
+rtc_library("default_audio_quality_analyzer") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -436,7 +436,7 @@
   ]
 }
 
-rtc_source_set("example_video_quality_analyzer") {
+rtc_library("example_video_quality_analyzer") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -454,7 +454,7 @@
   ]
 }
 
-rtc_source_set("default_video_quality_analyzer") {
+rtc_library("default_video_quality_analyzer") {
   visibility = [ "*" ]
 
   testonly = true
@@ -481,7 +481,7 @@
   ]
 }
 
-rtc_source_set("network_quality_metrics_reporter") {
+rtc_library("network_quality_metrics_reporter") {
   visibility = [ "*" ]
   testonly = true
   sources = [
@@ -499,7 +499,7 @@
   ]
 }
 
-rtc_source_set("sdp_changer") {
+rtc_library("sdp_changer") {
   testonly = true
   sources = [
     "sdp/sdp_changer.cc",
diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn
index 03bb1d6..a4e2c79 100644
--- a/test/peer_scenario/BUILD.gn
+++ b/test/peer_scenario/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_source_set("peer_scenario") {
+  rtc_library("peer_scenario") {
     testonly = true
     sources = [
       "peer_scenario.cc",
diff --git a/test/peer_scenario/tests/BUILD.gn b/test/peer_scenario/tests/BUILD.gn
index d799d2c..3552862 100644
--- a/test/peer_scenario/tests/BUILD.gn
+++ b/test/peer_scenario/tests/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_source_set("tests") {
+  rtc_library("tests") {
     testonly = true
     sources = [
       "peer_scenario_quality_test.cc",
diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn
index 1df39fa..e26df6b 100644
--- a/test/scenario/BUILD.gn
+++ b/test/scenario/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../../webrtc.gni")
 
-rtc_source_set("column_printer") {
+rtc_library("column_printer") {
   testonly = true
   sources = [
     "column_printer.cc",
@@ -48,7 +48,7 @@
   }
 }
 if (rtc_include_tests) {
-  rtc_source_set("scenario") {
+  rtc_library("scenario") {
     testonly = true
     sources = [
       "audio_stream.cc",
@@ -159,7 +159,7 @@
       deps += [ ":scenario_resources_bundle_data" ]
     }
   }
-  rtc_source_set("scenario_unittests") {
+  rtc_library("scenario_unittests") {
     testonly = true
     sources = [
       "performance_stats_unittest.cc",
diff --git a/test/time_controller/BUILD.gn b/test/time_controller/BUILD.gn
index aa12477..469683d 100644
--- a/test/time_controller/BUILD.gn
+++ b/test/time_controller/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_source_set("time_controller") {
+  rtc_library("time_controller") {
     testonly = true
     sources = [
       "real_time_controller.cc",
@@ -36,7 +36,7 @@
       "//third_party/abseil-cpp/absl/strings",
     ]
   }
-  rtc_source_set("time_controller_unittests") {
+  rtc_library("time_controller_unittests") {
     testonly = true
     sources = [
       "simulated_time_controller_unittest.cc",
diff --git a/tools_webrtc/presubmit_checks_lib/testdata/common_prefix/BUILD.gn b/tools_webrtc/presubmit_checks_lib/testdata/common_prefix/BUILD.gn
index b683408..ea10fb5 100644
--- a/tools_webrtc/presubmit_checks_lib/testdata/common_prefix/BUILD.gn
+++ b/tools_webrtc/presubmit_checks_lib/testdata/common_prefix/BUILD.gn
@@ -6,7 +6,7 @@
 # in the file PATENTS.  All contributing project authors may
 # be found in the AUTHORS file in the root of the source tree.
 
-rtc_static_library("webrtc") {
+rtc_library("webrtc") {
   sources = [
     "call.h",
     "dummy_source.h",
diff --git a/video/BUILD.gn b/video/BUILD.gn
index b1d1b9d..4f4ad96 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -8,7 +8,7 @@
 
 import("../webrtc.gni")
 
-rtc_static_library("video") {
+rtc_library("video") {
   sources = [
     "buffered_frame_decryptor.cc",
     "buffered_frame_decryptor.h",
@@ -128,7 +128,7 @@
   }
 }
 
-rtc_source_set("video_stream_decoder_impl") {
+rtc_library("video_stream_decoder_impl") {
   visibility = [ "*" ]
 
   sources = [
@@ -151,7 +151,7 @@
   ]
 }
 
-rtc_source_set("frame_dumping_decoder") {
+rtc_library("frame_dumping_decoder") {
   visibility = [ "*" ]
 
   sources = [
@@ -171,7 +171,7 @@
   ]
 }
 
-rtc_source_set("video_stream_encoder_impl") {
+rtc_library("video_stream_encoder_impl") {
   visibility = [ "*" ]
 
   # visibility = [ "../api/video:video_stream_encoder_create" ]
@@ -232,7 +232,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_source_set("video_mocks") {
+  rtc_library("video_mocks") {
     testonly = true
     sources = [
       "test/mock_video_stream_encoder.h",
@@ -242,7 +242,7 @@
       "../test:test_support",
     ]
   }
-  rtc_source_set("video_quality_test") {
+  rtc_library("video_quality_test") {
     testonly = true
 
     # Only targets in this file and api/ can depend on this.
@@ -314,7 +314,7 @@
     }
   }
 
-  rtc_source_set("video_full_stack_tests") {
+  rtc_library("video_full_stack_tests") {
     testonly = true
 
     sources = [
@@ -341,7 +341,7 @@
     ]
   }
 
-  rtc_source_set("video_pc_full_stack_tests") {
+  rtc_library("video_pc_full_stack_tests") {
     testonly = true
 
     sources = [
@@ -364,7 +364,7 @@
     ]
   }
 
-  rtc_static_library("video_loopback_lib") {
+  rtc_library("video_loopback_lib") {
     testonly = true
     sources = [
       "video_loopback.cc",
@@ -508,7 +508,7 @@
   }
 
   # TODO(pbos): Rename test suite.
-  rtc_source_set("video_tests") {
+  rtc_library("video_tests") {
     testonly = true
 
     defines = []
diff --git a/webrtc.gni b/webrtc.gni
index 2e6ccc8..6033764 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -300,17 +300,22 @@
   suppressed_configs = []
 }
 
+set_defaults("rtc_library") {
+  configs = rtc_add_configs
+  suppressed_configs = []
+}
+
 set_defaults("rtc_source_set") {
   configs = rtc_add_configs
   suppressed_configs = []
 }
 
-set_defaults("rtc_executable") {
+set_defaults("rtc_static_library") {
   configs = rtc_add_configs
   suppressed_configs = []
 }
 
-set_defaults("rtc_static_library") {
+set_defaults("rtc_executable") {
   configs = rtc_add_configs
   suppressed_configs = []
 }
@@ -485,46 +490,6 @@
   }
 }
 
-template("rtc_executable") {
-  executable(target_name) {
-    forward_variables_from(invoker,
-                           "*",
-                           [
-                             "deps",
-                             "configs",
-                             "public_configs",
-                             "suppressed_configs",
-                             "visibility",
-                           ])
-    forward_variables_from(invoker, [ "visibility" ])
-    if (!defined(visibility)) {
-      visibility = webrtc_default_visibility
-    }
-    configs += invoker.configs
-    configs -= rtc_remove_configs
-    configs -= invoker.suppressed_configs
-    deps = invoker.deps
-
-    public_configs = [
-      rtc_common_inherited_config,
-      absl_include_config,
-      absl_define_config,
-    ]
-    if (defined(testonly) && testonly) {
-      public_configs += [ absl_flags_config ]
-    }
-    if (defined(invoker.public_configs)) {
-      public_configs += invoker.public_configs
-    }
-    if (is_win) {
-      deps += [
-        # Give executables the default manifest on Windows (a no-op elsewhere).
-        "//build/win:default_exe_manifest",
-      ]
-    }
-  }
-}
-
 template("rtc_static_library") {
   static_library(target_name) {
     forward_variables_from(invoker,
@@ -600,6 +565,143 @@
   }
 }
 
+# This template automatically switches the target type between source_set
+# and static_library.
+#
+# This should be the default target type for all the WebRTC targets with
+# one exception. Do not use this template for header only targets, in that case
+# rtc_source_set must be used in order to avoid build errors (e.g. libtool
+# complains if the output .a file is empty).
+#
+# How does it work:
+# Since all files in a source_set are linked into a final binary, while files
+# in a static library are only linked in if at least one symbol in them is
+# referenced, in component builds source_sets are easy to deal with because
+# all their object files are passed to the linker to create a shared library.
+# In release builds instead, static_libraries are preferred since they allow
+# the linker to discard dead code.
+# For the same reason, testonly targets will always be expanded to
+# source_set in order to be sure that tests are present in the test binary.
+template("rtc_library") {
+  if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
+    target_type = "source_set"
+  } else {
+    target_type = "static_library"
+  }
+  target(target_type, target_name) {
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "configs",
+                             "public_configs",
+                             "suppressed_configs",
+                             "visibility",
+                           ])
+    forward_variables_from(invoker, [ "visibility" ])
+    if (!defined(visibility)) {
+      visibility = webrtc_default_visibility
+    }
+
+    # What's your poison?
+    if (defined(testonly) && testonly) {
+      assert(!defined(poisonous))
+      assert(!defined(allow_poison))
+    } else {
+      if (!defined(poisonous)) {
+        poisonous = []
+      }
+      if (!defined(allow_poison)) {
+        allow_poison = []
+      }
+      if (!defined(assert_no_deps)) {
+        assert_no_deps = []
+      }
+      if (!defined(deps)) {
+        deps = []
+      }
+      foreach(p, poisonous) {
+        deps += [ webrtc_root + ":poison_" + p ]
+      }
+      foreach(poison_type, all_poison_types) {
+        allow_dep = true
+        foreach(v, visibility) {
+          if (v == "*") {
+            allow_dep = false
+          }
+        }
+        foreach(p, allow_poison + poisonous) {
+          if (p == poison_type) {
+            allow_dep = true
+          }
+        }
+        if (!allow_dep) {
+          assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
+        }
+      }
+    }
+
+    if (!defined(testonly) || !testonly) {
+      configs += rtc_prod_configs
+    }
+
+    configs += invoker.configs
+    configs += rtc_library_impl_config
+    configs -= rtc_remove_configs
+    configs -= invoker.suppressed_configs
+    public_configs = [
+      rtc_common_inherited_config,
+      absl_include_config,
+      absl_define_config,
+    ]
+    if (defined(testonly) && testonly) {
+      public_configs += [ absl_flags_config ]
+    }
+    if (defined(invoker.public_configs)) {
+      public_configs += invoker.public_configs
+    }
+  }
+}
+
+template("rtc_executable") {
+  executable(target_name) {
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "deps",
+                             "configs",
+                             "public_configs",
+                             "suppressed_configs",
+                             "visibility",
+                           ])
+    forward_variables_from(invoker, [ "visibility" ])
+    if (!defined(visibility)) {
+      visibility = webrtc_default_visibility
+    }
+    configs += invoker.configs
+    configs -= rtc_remove_configs
+    configs -= invoker.suppressed_configs
+    deps = invoker.deps
+
+    public_configs = [
+      rtc_common_inherited_config,
+      absl_include_config,
+      absl_define_config,
+    ]
+    if (defined(testonly) && testonly) {
+      public_configs += [ absl_flags_config ]
+    }
+    if (defined(invoker.public_configs)) {
+      public_configs += invoker.public_configs
+    }
+    if (is_win) {
+      deps += [
+        # Give executables the default manifest on Windows (a no-op elsewhere).
+        "//build/win:default_exe_manifest",
+      ]
+    }
+  }
+}
+
 template("rtc_shared_library") {
   shared_library(target_name) {
     forward_variables_from(invoker,