Bug 14156

Summary: 1.34 fails to build on MIPS
Product: Busybox Reporter: Tianon Gravi <admwiggin+busyboxbugs>
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Tianon Gravi 2021-08-19 22:23:19 UTC
Hi!  I'm getting the following failure when trying to build 1.34.0 on MIPS (specifically, mips64le):

In file included from networking/udhcp/common.c:7:
networking/udhcp/common.h:277:20: error: expected identifier or '(' before 'do'
  277 | # define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0)
      |                    ^~
networking/udhcp/common.h:316:15: note: in expansion of macro 'log1'
  316 | #define log1s log1
      |               ^~~~
networking/udhcp/common.c:189:16: note: in expansion of macro 'log1s'
  189 | void FAST_FUNC log1s(const char *msg)
      |                ^~~~~
networking/udhcp/common.h:277:76: error: expected identifier or '(' before 'while'
  277 | # define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0)
      |                                                                            ^~~~~
networking/udhcp/common.h:316:15: note: in expansion of macro 'log1'
  316 | #define log1s log1
      |               ^~~~
networking/udhcp/common.c:189:16: note: in expansion of macro 'log1s'
  189 | void FAST_FUNC log1s(const char *msg)
      |                ^~~~~
make[1]: *** [scripts/Makefile.build:197: networking/udhcp/common.o] Error 1
make: *** [Makefile:744: networking/udhcp] Error 2

I *believe* this is due to a combination of 774020c224653590110b30ea461d0ead34a6d875 ("udhcp: convert log1s() macro to function") and the "#if defined(__mips__)" block in "networking/udhcp/common.h" which does "#undef log1s" (but now "log1s" is sometimes a function instead).

I think either that #undef+#define should go away (depending on whether it's still relevant) or should become further conditional with something like "#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1" to match the function declaration in "networking/udhcp/common.c"?
Comment 1 Denys Vlasenko 2021-08-19 22:43:12 UTC
Does it work if you remove entire "#if defined(__mips__)" block?
Comment 2 Tianon Gravi 2021-08-20 01:49:08 UTC
Confirmed, removed the entire "#if defined(__mips__)" block and it compiles successfully:

diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 8c678dd32..ca778dab8 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -304,18 +304,6 @@ void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
 # define log3s(msg) ((void)0)
 #endif
 
-#if defined(__mips__)
-/*
- * The 'simple' message functions have a negative impact on the size of the
- * DHCP code when compiled for MIPS, so don't use them in this case.
- */
-#define bb_simple_info_msg bb_info_msg
-#define bb_simple_error_msg bb_error_msg
-#define bb_simple_perror_msg_and_die bb_perror_msg_and_die
-#undef log1s
-#define log1s log1
-#endif
-
 /*** Other shared functions ***/
 
 /* 2nd param is "uint32_t*" */
Comment 3 Denys Vlasenko 2021-08-20 14:12:59 UTC
Fixed in git.