Skip to content

adb: keep libbase logging macros after protobuf includes - #213

Merged
Biswa96 merged 2 commits into
nmeum:masterfrom
munix9:protobuf-36
Sep 30, 2026
Merged

Biswa96 merged 2 commits into
nmeum:masterfrom
munix9:protobuf-36

Conversation

@munix9

@munix9 munix9 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Fix build with protobuf >= 36
Based on arch linux patch
https://gitlab.archlinux.org/archlinux/packaging/packages/android-tools/-/blob/03fecd370e9633927b8157ab94a7db11e7b8cf16/protobuf-36-absl-log-macros.patch

Please create a new release (eg. 37.0.0p1) if this PR is accepted.

@Biswa96

Biswa96 commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the contribution. I can reproduce the build error in ArchLinux. The build output shows a warning first as following but it causes compiler error later.

  • Warning:
android-tools/vendor/adb/adb_trace.h:52:9: warning: ‘VLOG’ redefined
   52 | #define VLOG(TAG)                 \
      |         ^~~~

/usr/include/absl/log/log.h:250:9: note: this is the location of the previous definition
  250 | #define VLOG(verbose_level) ABSL_LOG_INTERNAL_VLOG_IMPL(verbose_level)
      |         ^~~~
  • Error:
android-tools/vendor/adb/adb_trace.h:56:9: error: ‘STATELESS’ was not declared in this scope
   56 |         LOG(DEBUG)
      |         ^~~
android-tools/vendor/adb/client/mdns_tracker.cpp:101:5: note: in expansion of macro ‘VLOG’
  101 |     VLOG(MDNS) << "mdns tracker removed";
      |     ^~~~

The patch seems to be based on the assumption that "sysdeps.h is the first include for most adb translation units". Anyway, I can't think of a better solution :)

@Biswa96

Biswa96 commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

I just realized that adb install command now shows an warning message as following.

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1790496358.574016   29891 adb_install.cpp:153] pm command: 'package install -S 40717542'

Would it be possible to add the following section in the patch file? This redefines the logging macro like it was done in mdns_tracker.cpp. @felixonmars

--- a/client/adb_install.cpp
+++ b/client/adb_install.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include "sysdeps.h"
 #include "adb_install.h"
 
 #include <fcntl.h>
@@ -39,7 +40,6 @@
 #include "commandline.h"
 #include "fastdeploy.h"
 #include "incremental.h"
-#include "sysdeps.h"
 
 using namespace std::literals;

@Biswa96
Biswa96 merged commit 9a1844a into nmeum:master Sep 30, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants