Commit c7c8ea6a authored by Kumar Gala's avatar Kumar Gala Committed by Anas Nashif
Browse files

logging: Fix build issues with arm-clang



The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined.  To fix this add needed ifdef'ry.

Fixes #56630
Fixes #56628

Signed-off-by: default avatarKumar Gala <kumar.gala@intel.com>
parent 20f82253
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ static STRUCT_SECTION_ITERABLE(log_msg_ptr, log_msg_ptr);
static STRUCT_SECTION_ITERABLE_ALTERNATE(log_mpsc_pbuf, mpsc_pbuf_buffer, log_buffer);
static struct mpsc_pbuf_buffer *curr_log_buffer;

#ifdef CONFIG_MPSC_PBUF
static uint32_t __aligned(Z_LOG_MSG_ALIGNMENT)
	buf32[CONFIG_LOG_BUFFER_SIZE / sizeof(int)];

@@ -128,6 +129,7 @@ static const struct mpsc_pbuf_buffer_config mpsc_config = {
		 (IS_ENABLED(CONFIG_LOG_MEM_UTILIZATION) ?
		  MPSC_PBUF_MAX_UTILIZATION : 0)
};
#endif

/* Check that default tag can fit in tag buffer. */
COND_CODE_0(CONFIG_LOG_TAG_MAX_LEN, (),
@@ -581,8 +583,10 @@ bool z_log_dropped_pending(void)

void z_log_msg_init(void)
{
#ifdef CONFIG_MPSC_PBUF
	mpsc_pbuf_init(&log_buffer, &mpsc_config);
	curr_log_buffer = &log_buffer;
#endif
}

static struct log_msg *msg_alloc(struct mpsc_pbuf_buffer *buffer, uint32_t wlen)
@@ -610,7 +614,9 @@ static void msg_commit(struct mpsc_pbuf_buffer *buffer, struct log_msg *msg)
		return;
	}

#ifdef CONFIG_MPSC_PBUF
	mpsc_pbuf_commit(buffer, &m->buf);
#endif
	z_log_msg_post_finalize();
}

@@ -622,7 +628,12 @@ void z_log_msg_commit(struct log_msg *msg)

union log_msg_generic *z_log_msg_local_claim(void)
{
#ifdef CONFIG_MPSC_PBUF
	return (union log_msg_generic *)mpsc_pbuf_claim(&log_buffer);
#else
	return NULL;
#endif

}

/* If there are buffers dedicated for each link, claim the oldest message (lowest timestamp). */
@@ -640,9 +651,11 @@ union log_msg_generic *z_log_msg_claim_oldest(k_timeout_t *backoff)

		STRUCT_SECTION_GET(log_mpsc_pbuf, i, &buf);

#ifdef CONFIG_MPSC_PBUF
		if (msg_ptr->msg == NULL) {
			msg_ptr->msg = (union log_msg_generic *)mpsc_pbuf_claim(&buf->buf);
		}
#endif

		if (msg_ptr->msg) {
			log_timestamp_t t = log_msg_get_timestamp(&msg_ptr->msg->log);
@@ -706,7 +719,9 @@ union log_msg_generic *z_log_msg_claim(k_timeout_t *backoff)

static void msg_free(struct mpsc_pbuf_buffer *buffer, const union log_msg_generic *msg)
{
#ifdef CONFIG_MPSC_PBUF
	mpsc_pbuf_free(buffer, &msg->buf);
#endif
}

void z_log_msg_free(union log_msg_generic *msg)
@@ -716,7 +731,11 @@ void z_log_msg_free(union log_msg_generic *msg)

static bool msg_pending(struct mpsc_pbuf_buffer *buffer)
{
#ifdef CONFIG_MPSC_PBUF
	return mpsc_pbuf_is_pending(buffer);
#else
	return false;
#endif
}

bool z_log_msg_pending(void)
+6 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ uint32_t *z_log_link_get_dynamic_filter(uint8_t domain_id, uint32_t source_id)
	return &link->ctrl_blk->filters[source_offset + source_id];
}

#ifdef CONFIG_LOG_MULTIDOMAIN
static int link_filters_init(const struct log_link *link)
{
	uint32_t total_cnt = get_source_offset(link, link->ctrl_blk->domain_cnt);
@@ -146,6 +147,7 @@ static int link_filters_init(const struct log_link *link)

	return 0;
}
#endif

static void cache_init(void)
{
@@ -558,15 +560,18 @@ void z_log_links_initiate(void)
	cache_init();

	STRUCT_SECTION_FOREACH(log_link, link) {
#ifdef CONFIG_MPSC_PBUF
		if (link->mpsc_pbuf) {
			mpsc_pbuf_init(link->mpsc_pbuf, link->mpsc_pbuf_config);
		}
#endif

		err = log_link_initiate(link, NULL);
		__ASSERT(err == 0, "Failed to initialize link");
	}
}

#ifdef CONFIG_LOG_MULTIDOMAIN
static void backends_link_init(const struct log_link *link)
{
	for (int i = 0; i < log_backend_count_get(); i++) {
@@ -616,3 +621,4 @@ uint32_t z_log_links_activate(uint32_t active_mask, uint8_t *offset)

	return out_mask;
}
#endif