You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

423 lines
20 KiB

lttng-tools: musl compile fixes Add two patches to address three distinct build problems spotted by our build bots when compiling lttng-tools: 1) unconditional use of `__GLIBC_PREREQ` On musl based toolchains there is no such macro defined, leading to the following preprocessor error: CC compat-epoll.lo In file included from compat-epoll.c:33:0: poll.h:76:19: error: missing binary operator before token "(" #if __GLIBC_PREREQ(2, 9) 2) undeclared `mode_t` type On musl based toolchains the `mode_t` type is not implicitely defined through other includes, leading to the following compile error: CC hashtable.lo In file included from ../../../src/common/common.h:24:0, from hashtable.c:24: ../../../src/common/runas.h:25:46: error: unknown type name 'mode_t' int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid); ^ ../../../src/common/runas.h:26:36: error: unknown type name 'mode_t' int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid); ^ ../../../src/common/runas.h:27:46: error: unknown type name 'mode_t' int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid); ^ 3) multiple definitions The header files declare several `const char *` pointers which are initialized in various `*.c` files later on. Due to a missing `extern` declaration in the header, the final linking of the executables fails with errors such as: CCLD lttng ../../../src/common/.libs/libcommon.a(mi-lttng.o):(.data.rel.ro.local+0x0): multiple definition of `mi_lttng_element_snapshots' commands/enable_events.o:(.bss+0x18): first defined here collect2: error: ld returned 1 exit status This commits addresses these issues with two patches, `100-musl-compat.patch` fixes issue 1 by declaring a fallback dummy declaration of `__GLIBC_PREREQ` and issue 2 by explicitely including `sys/stat.h` which provides `mode_t` according to POSIX. The second patch, `200-use-extern.patch` declares all char pointers in the header file as `extern`, fixing the observed linker errors. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
9 years ago
  1. --- a/src/common/mi-lttng.h
  2. +++ b/src/common/mi-lttng.h
  3. @@ -49,133 +49,133 @@ struct mi_lttng_version {
  4. };
  5. /* Strings related to command */
  6. -const char * const mi_lttng_element_command;
  7. -const char * const mi_lttng_element_command_action;
  8. -const char * const mi_lttng_element_command_add_context;
  9. -const char * const mi_lttng_element_command_calibrate;
  10. -const char * const mi_lttng_element_command_create;
  11. -const char * const mi_lttng_element_command_destroy;
  12. -const char * const mi_lttng_element_command_disable_channel;
  13. -const char * const mi_lttng_element_command_disable_event;
  14. -const char * const mi_lttng_element_command_enable_channels;
  15. -const char * const mi_lttng_element_command_enable_event;
  16. -const char * const mi_lttng_element_command_list;
  17. -const char * const mi_lttng_element_command_load;
  18. -const char * const mi_lttng_element_command_name;
  19. -const char * const mi_lttng_element_command_output;
  20. -const char * const mi_lttng_element_command_save;
  21. -const char * const mi_lttng_element_command_set_session;
  22. -const char * const mi_lttng_element_command_snapshot;
  23. -const char * const mi_lttng_element_command_snapshot_add;
  24. -const char * const mi_lttng_element_command_snapshot_del;
  25. -const char * const mi_lttng_element_command_snapshot_list;
  26. -const char * const mi_lttng_element_command_snapshot_record;
  27. -const char * const mi_lttng_element_command_start;
  28. -const char * const mi_lttng_element_command_stop;
  29. -const char * const mi_lttng_element_command_success;
  30. -const char * const mi_lttng_element_command_version;
  31. +extern const char * const mi_lttng_element_command;
  32. +extern const char * const mi_lttng_element_command_action;
  33. +extern const char * const mi_lttng_element_command_add_context;
  34. +extern const char * const mi_lttng_element_command_calibrate;
  35. +extern const char * const mi_lttng_element_command_create;
  36. +extern const char * const mi_lttng_element_command_destroy;
  37. +extern const char * const mi_lttng_element_command_disable_channel;
  38. +extern const char * const mi_lttng_element_command_disable_event;
  39. +extern const char * const mi_lttng_element_command_enable_channels;
  40. +extern const char * const mi_lttng_element_command_enable_event;
  41. +extern const char * const mi_lttng_element_command_list;
  42. +extern const char * const mi_lttng_element_command_load;
  43. +extern const char * const mi_lttng_element_command_name;
  44. +extern const char * const mi_lttng_element_command_output;
  45. +extern const char * const mi_lttng_element_command_save;
  46. +extern const char * const mi_lttng_element_command_set_session;
  47. +extern const char * const mi_lttng_element_command_snapshot;
  48. +extern const char * const mi_lttng_element_command_snapshot_add;
  49. +extern const char * const mi_lttng_element_command_snapshot_del;
  50. +extern const char * const mi_lttng_element_command_snapshot_list;
  51. +extern const char * const mi_lttng_element_command_snapshot_record;
  52. +extern const char * const mi_lttng_element_command_start;
  53. +extern const char * const mi_lttng_element_command_stop;
  54. +extern const char * const mi_lttng_element_command_success;
  55. +extern const char * const mi_lttng_element_command_version;
  56. /* Strings related to version command */
  57. -const char * const mi_lttng_element_version;
  58. -const char * const mi_lttng_element_version_commit;
  59. -const char * const mi_lttng_element_version_description;
  60. -const char * const mi_lttng_element_version_license;
  61. -const char * const mi_lttng_element_version_major;
  62. -const char * const mi_lttng_element_version_minor;
  63. -const char * const mi_lttng_element_version_patch_level;
  64. -const char * const mi_lttng_element_version_str;
  65. -const char * const mi_lttng_element_version_web;
  66. +extern const char * const mi_lttng_element_version;
  67. +extern const char * const mi_lttng_element_version_commit;
  68. +extern const char * const mi_lttng_element_version_description;
  69. +extern const char * const mi_lttng_element_version_license;
  70. +extern const char * const mi_lttng_element_version_major;
  71. +extern const char * const mi_lttng_element_version_minor;
  72. +extern const char * const mi_lttng_element_version_patch_level;
  73. +extern const char * const mi_lttng_element_version_str;
  74. +extern const char * const mi_lttng_element_version_web;
  75. /* String related to a lttng_event_field */
  76. -const char * const mi_lttng_element_event_field;
  77. -const char * const mi_lttng_element_event_fields;
  78. +extern const char * const mi_lttng_element_event_field;
  79. +extern const char * const mi_lttng_element_event_fields;
  80. /* String related to lttng_event_context */
  81. -const char * const mi_lttng_context_type_perf_counter;
  82. -const char * const mi_lttng_context_type_perf_cpu_counter;
  83. -const char * const mi_lttng_context_type_perf_thread_counter;
  84. +extern const char * const mi_lttng_context_type_perf_counter;
  85. +extern const char * const mi_lttng_context_type_perf_cpu_counter;
  86. +extern const char * const mi_lttng_context_type_perf_thread_counter;
  87. /* String related to lttng_event_perf_counter_ctx */
  88. -const char * const mi_lttng_element_perf_counter_context;
  89. +extern const char * const mi_lttng_element_perf_counter_context;
  90. /* Strings related to pid */
  91. -const char * const mi_lttng_element_pids;
  92. -const char * const mi_lttng_element_pid;
  93. -const char * const mi_lttng_element_pid_id;
  94. +extern const char * const mi_lttng_element_pids;
  95. +extern const char * const mi_lttng_element_pid;
  96. +extern const char * const mi_lttng_element_pid_id;
  97. /* Strings related to save command */
  98. -const char * const mi_lttng_element_save;
  99. +extern const char * const mi_lttng_element_save;
  100. /* Strings related to load command */
  101. -const char * const mi_lttng_element_load;
  102. +extern const char * const mi_lttng_element_load;
  103. /* General element of mi_lttng */
  104. -const char * const mi_lttng_element_empty;
  105. -const char * const mi_lttng_element_id;
  106. -const char * const mi_lttng_element_nowrite;
  107. -const char * const mi_lttng_element_success;
  108. -const char * const mi_lttng_element_type_enum;
  109. -const char * const mi_lttng_element_type_float;
  110. -const char * const mi_lttng_element_type_integer;
  111. -const char * const mi_lttng_element_type_other;
  112. -const char * const mi_lttng_element_type_string;
  113. +extern const char * const mi_lttng_element_empty;
  114. +extern const char * const mi_lttng_element_id;
  115. +extern const char * const mi_lttng_element_nowrite;
  116. +extern const char * const mi_lttng_element_success;
  117. +extern const char * const mi_lttng_element_type_enum;
  118. +extern const char * const mi_lttng_element_type_float;
  119. +extern const char * const mi_lttng_element_type_integer;
  120. +extern const char * const mi_lttng_element_type_other;
  121. +extern const char * const mi_lttng_element_type_string;
  122. /* String related to loglevel */
  123. -const char * const mi_lttng_loglevel_str_alert;
  124. -const char * const mi_lttng_loglevel_str_crit;
  125. -const char * const mi_lttng_loglevel_str_debug;
  126. -const char * const mi_lttng_loglevel_str_debug_function;
  127. -const char * const mi_lttng_loglevel_str_debug_line;
  128. -const char * const mi_lttng_loglevel_str_debug_module;
  129. -const char * const mi_lttng_loglevel_str_debug_process;
  130. -const char * const mi_lttng_loglevel_str_debug_program;
  131. -const char * const mi_lttng_loglevel_str_debug_system;
  132. -const char * const mi_lttng_loglevel_str_debug_unit;
  133. -const char * const mi_lttng_loglevel_str_emerg;
  134. -const char * const mi_lttng_loglevel_str_err;
  135. -const char * const mi_lttng_loglevel_str_info;
  136. -const char * const mi_lttng_loglevel_str_notice;
  137. -const char * const mi_lttng_loglevel_str_unknown;
  138. -const char * const mi_lttng_loglevel_str_warning;
  139. +extern const char * const mi_lttng_loglevel_str_alert;
  140. +extern const char * const mi_lttng_loglevel_str_crit;
  141. +extern const char * const mi_lttng_loglevel_str_debug;
  142. +extern const char * const mi_lttng_loglevel_str_debug_function;
  143. +extern const char * const mi_lttng_loglevel_str_debug_line;
  144. +extern const char * const mi_lttng_loglevel_str_debug_module;
  145. +extern const char * const mi_lttng_loglevel_str_debug_process;
  146. +extern const char * const mi_lttng_loglevel_str_debug_program;
  147. +extern const char * const mi_lttng_loglevel_str_debug_system;
  148. +extern const char * const mi_lttng_loglevel_str_debug_unit;
  149. +extern const char * const mi_lttng_loglevel_str_emerg;
  150. +extern const char * const mi_lttng_loglevel_str_err;
  151. +extern const char * const mi_lttng_loglevel_str_info;
  152. +extern const char * const mi_lttng_loglevel_str_notice;
  153. +extern const char * const mi_lttng_loglevel_str_unknown;
  154. +extern const char * const mi_lttng_loglevel_str_warning;
  155. /* String related to loglevel JUL */
  156. -const char * const mi_lttng_loglevel_str_jul_all;
  157. -const char * const mi_lttng_loglevel_str_jul_config;
  158. -const char * const mi_lttng_loglevel_str_jul_fine;
  159. -const char * const mi_lttng_loglevel_str_jul_finer;
  160. -const char * const mi_lttng_loglevel_str_jul_finest;
  161. -const char * const mi_lttng_loglevel_str_jul_info;
  162. -const char * const mi_lttng_loglevel_str_jul_off;
  163. -const char * const mi_lttng_loglevel_str_jul_severe;
  164. -const char * const mi_lttng_loglevel_str_jul_warning;
  165. +extern const char * const mi_lttng_loglevel_str_jul_all;
  166. +extern const char * const mi_lttng_loglevel_str_jul_config;
  167. +extern const char * const mi_lttng_loglevel_str_jul_fine;
  168. +extern const char * const mi_lttng_loglevel_str_jul_finer;
  169. +extern const char * const mi_lttng_loglevel_str_jul_finest;
  170. +extern const char * const mi_lttng_loglevel_str_jul_info;
  171. +extern const char * const mi_lttng_loglevel_str_jul_off;
  172. +extern const char * const mi_lttng_loglevel_str_jul_severe;
  173. +extern const char * const mi_lttng_loglevel_str_jul_warning;
  174. /* String related to loglevel Log4j */
  175. -const char * const mi_lttng_loglevel_str_log4j_off;
  176. -const char * const mi_lttng_loglevel_str_log4j_fatal;
  177. -const char * const mi_lttng_loglevel_str_log4j_error;
  178. -const char * const mi_lttng_loglevel_str_log4j_warn;
  179. -const char * const mi_lttng_loglevel_str_log4j_info;
  180. -const char * const mi_lttng_loglevel_str_log4j_debug;
  181. -const char * const mi_lttng_loglevel_str_log4j_trace;
  182. -const char * const mi_lttng_loglevel_str_log4j_all;
  183. +extern const char * const mi_lttng_loglevel_str_log4j_off;
  184. +extern const char * const mi_lttng_loglevel_str_log4j_fatal;
  185. +extern const char * const mi_lttng_loglevel_str_log4j_error;
  186. +extern const char * const mi_lttng_loglevel_str_log4j_warn;
  187. +extern const char * const mi_lttng_loglevel_str_log4j_info;
  188. +extern const char * const mi_lttng_loglevel_str_log4j_debug;
  189. +extern const char * const mi_lttng_loglevel_str_log4j_trace;
  190. +extern const char * const mi_lttng_loglevel_str_log4j_all;
  191. /* String related to loglevel type */
  192. -const char * const mi_lttng_loglevel_type_all;
  193. -const char * const mi_lttng_loglevel_type_range;
  194. -const char * const mi_lttng_loglevel_type_single;
  195. -const char * const mi_lttng_loglevel_type_unknown;
  196. +extern const char * const mi_lttng_loglevel_type_all;
  197. +extern const char * const mi_lttng_loglevel_type_range;
  198. +extern const char * const mi_lttng_loglevel_type_single;
  199. +extern const char * const mi_lttng_loglevel_type_unknown;
  200. /* Sting related to lttng_calibrate */
  201. -const char * const mi_lttng_element_calibrate;
  202. -const char * const mi_lttng_element_calibrate_function;
  203. +extern const char * const mi_lttng_element_calibrate;
  204. +extern const char * const mi_lttng_element_calibrate_function;
  205. /* String related to a lttng_snapshot */
  206. -const char * const mi_lttng_element_snapshot_ctrl_url;
  207. -const char * const mi_lttng_element_snapshot_data_url;
  208. -const char * const mi_lttng_element_snapshot_max_size;
  209. -const char * const mi_lttng_element_snapshot_n_ptr;
  210. -const char * const mi_lttng_element_snapshot_session_name;
  211. -const char * const mi_lttng_element_snapshots;
  212. +extern const char * const mi_lttng_element_snapshot_ctrl_url;
  213. +extern const char * const mi_lttng_element_snapshot_data_url;
  214. +extern const char * const mi_lttng_element_snapshot_max_size;
  215. +extern const char * const mi_lttng_element_snapshot_n_ptr;
  216. +extern const char * const mi_lttng_element_snapshot_session_name;
  217. +extern const char * const mi_lttng_element_snapshots;
  218. /* Utility string function */
  219. const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
  220. --- a/src/common/config/config-session-abi.h
  221. +++ b/src/common/config/config-session-abi.h
  222. @@ -18,95 +18,95 @@
  223. #ifndef CONFIG_SESSION_INTERNAL_H
  224. #define CONFIG_SESSION_INTERNAL_H
  225. -const char * const config_element_channel;
  226. -const char * const config_element_channels;
  227. -const char * const config_element_domain;
  228. -const char * const config_element_domains;
  229. -const char * const config_element_event;
  230. -const char * const config_element_events;
  231. -const char * const config_element_context;
  232. -const char * const config_element_contexts;
  233. -const char * const config_element_attributes;
  234. -const char * const config_element_exclusion;
  235. -const char * const config_element_exclusions;
  236. -const char * const config_element_function_attributes;
  237. -const char * const config_element_probe_attributes;
  238. -const char * const config_element_symbol_name;
  239. -const char * const config_element_address;
  240. -const char * const config_element_offset;
  241. -const char * const config_element_name;
  242. -const char * const config_element_enabled;
  243. -const char * const config_element_overwrite_mode;
  244. -const char * const config_element_subbuf_size;
  245. -const char * const config_element_num_subbuf;
  246. -const char * const config_element_switch_timer_interval;
  247. -const char * const config_element_read_timer_interval;
  248. -const char * const config_element_output;
  249. -const char * const config_element_output_type;
  250. -const char * const config_element_tracefile_size;
  251. -const char * const config_element_tracefile_count;
  252. -const char * const config_element_live_timer_interval;
  253. -const char * const config_element_type;
  254. -const char * const config_element_buffer_type;
  255. -const char * const config_element_session;
  256. -const char * const config_element_sessions;
  257. -const char * const config_element_perf;
  258. -const char * const config_element_config;
  259. -const char * const config_element_started;
  260. -const char * const config_element_snapshot_mode;
  261. -const char * const config_element_loglevel;
  262. -const char * const config_element_loglevel_type;
  263. -const char * const config_element_filter;
  264. -const char * const config_element_snapshot_outputs;
  265. -const char * const config_element_consumer_output;
  266. -const char * const config_element_destination;
  267. -const char * const config_element_path;
  268. -const char * const config_element_net_output;
  269. -const char * const config_element_control_uri;
  270. -const char * const config_element_data_uri;
  271. -const char * const config_element_max_size;
  272. -
  273. -const char * const config_domain_type_kernel;
  274. -const char * const config_domain_type_ust;
  275. -const char * const config_domain_type_jul;
  276. -const char * const config_domain_type_log4j;
  277. -
  278. -const char * const config_buffer_type_per_pid;
  279. -const char * const config_buffer_type_per_uid;
  280. -const char * const config_buffer_type_global;
  281. -
  282. -const char * const config_overwrite_mode_discard;
  283. -const char * const config_overwrite_mode_overwrite;
  284. -
  285. -const char * const config_output_type_splice;
  286. -const char * const config_output_type_mmap;
  287. -
  288. -const char * const config_loglevel_type_all;
  289. -const char * const config_loglevel_type_range;
  290. -const char * const config_loglevel_type_single;
  291. -
  292. -const char * const config_event_type_all;
  293. -const char * const config_event_type_tracepoint;
  294. -const char * const config_event_type_probe;
  295. -const char * const config_event_type_function;
  296. -const char * const config_event_type_function_entry;
  297. -const char * const config_event_type_noop;
  298. -const char * const config_event_type_syscall;
  299. -const char * const config_event_type_kprobe;
  300. -const char * const config_event_type_kretprobe;
  301. -
  302. -const char * const config_event_context_pid;
  303. -const char * const config_event_context_procname;
  304. -const char * const config_event_context_prio;
  305. -const char * const config_event_context_nice;
  306. -const char * const config_event_context_vpid;
  307. -const char * const config_event_context_tid;
  308. -const char * const config_event_context_vtid;
  309. -const char * const config_event_context_ppid;
  310. -const char * const config_event_context_vppid;
  311. -const char * const config_event_context_pthread_id;
  312. -const char * const config_event_context_hostname;
  313. -const char * const config_event_context_ip;
  314. -const char * const config_event_context_perf_thread_counter;
  315. +extern const char * const config_element_channel;
  316. +extern const char * const config_element_channels;
  317. +extern const char * const config_element_domain;
  318. +extern const char * const config_element_domains;
  319. +extern const char * const config_element_event;
  320. +extern const char * const config_element_events;
  321. +extern const char * const config_element_context;
  322. +extern const char * const config_element_contexts;
  323. +extern const char * const config_element_attributes;
  324. +extern const char * const config_element_exclusion;
  325. +extern const char * const config_element_exclusions;
  326. +extern const char * const config_element_function_attributes;
  327. +extern const char * const config_element_probe_attributes;
  328. +extern const char * const config_element_symbol_name;
  329. +extern const char * const config_element_address;
  330. +extern const char * const config_element_offset;
  331. +extern const char * const config_element_name;
  332. +extern const char * const config_element_enabled;
  333. +extern const char * const config_element_overwrite_mode;
  334. +extern const char * const config_element_subbuf_size;
  335. +extern const char * const config_element_num_subbuf;
  336. +extern const char * const config_element_switch_timer_interval;
  337. +extern const char * const config_element_read_timer_interval;
  338. +extern const char * const config_element_output;
  339. +extern const char * const config_element_output_type;
  340. +extern const char * const config_element_tracefile_size;
  341. +extern const char * const config_element_tracefile_count;
  342. +extern const char * const config_element_live_timer_interval;
  343. +extern const char * const config_element_type;
  344. +extern const char * const config_element_buffer_type;
  345. +extern const char * const config_element_session;
  346. +extern const char * const config_element_sessions;
  347. +extern const char * const config_element_perf;
  348. +extern const char * const config_element_config;
  349. +extern const char * const config_element_started;
  350. +extern const char * const config_element_snapshot_mode;
  351. +extern const char * const config_element_loglevel;
  352. +extern const char * const config_element_loglevel_type;
  353. +extern const char * const config_element_filter;
  354. +extern const char * const config_element_snapshot_outputs;
  355. +extern const char * const config_element_consumer_output;
  356. +extern const char * const config_element_destination;
  357. +extern const char * const config_element_path;
  358. +extern const char * const config_element_net_output;
  359. +extern const char * const config_element_control_uri;
  360. +extern const char * const config_element_data_uri;
  361. +extern const char * const config_element_max_size;
  362. +
  363. +extern const char * const config_domain_type_kernel;
  364. +extern const char * const config_domain_type_ust;
  365. +extern const char * const config_domain_type_jul;
  366. +extern const char * const config_domain_type_log4j;
  367. +
  368. +extern const char * const config_buffer_type_per_pid;
  369. +extern const char * const config_buffer_type_per_uid;
  370. +extern const char * const config_buffer_type_global;
  371. +
  372. +extern const char * const config_overwrite_mode_discard;
  373. +extern const char * const config_overwrite_mode_overwrite;
  374. +
  375. +extern const char * const config_output_type_splice;
  376. +extern const char * const config_output_type_mmap;
  377. +
  378. +extern const char * const config_loglevel_type_all;
  379. +extern const char * const config_loglevel_type_range;
  380. +extern const char * const config_loglevel_type_single;
  381. +
  382. +extern const char * const config_event_type_all;
  383. +extern const char * const config_event_type_tracepoint;
  384. +extern const char * const config_event_type_probe;
  385. +extern const char * const config_event_type_function;
  386. +extern const char * const config_event_type_function_entry;
  387. +extern const char * const config_event_type_noop;
  388. +extern const char * const config_event_type_syscall;
  389. +extern const char * const config_event_type_kprobe;
  390. +extern const char * const config_event_type_kretprobe;
  391. +
  392. +extern const char * const config_event_context_pid;
  393. +extern const char * const config_event_context_procname;
  394. +extern const char * const config_event_context_prio;
  395. +extern const char * const config_event_context_nice;
  396. +extern const char * const config_event_context_vpid;
  397. +extern const char * const config_event_context_tid;
  398. +extern const char * const config_event_context_vtid;
  399. +extern const char * const config_event_context_ppid;
  400. +extern const char * const config_event_context_vppid;
  401. +extern const char * const config_event_context_pthread_id;
  402. +extern const char * const config_event_context_hostname;
  403. +extern const char * const config_event_context_ip;
  404. +extern const char * const config_event_context_perf_thread_counter;
  405. #endif /* CONFIG_SESSION_INTERNAL_H */