You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/02/25 14:38:51 UTC

[mynewt-newt] branch master updated: toolchain: Link all archives with -whole-archive

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 807df4f  toolchain: Link all archives with -whole-archive
807df4f is described below

commit 807df4f13976cc477bf505f36fd36011c5836c5a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Feb 21 15:02:04 2022 +0100

    toolchain: Link all archives with -whole-archive
    
    Using -whole-archives guarantees that all objects from .a files are
    included in build. It should not affect regular builds since we want to
    include all objects from Mynewt packages anyway, but it helps to resolve
    weak symbols properly if weak and non-weak counterparts are defined in
    the same package/library/archive.
---
 newt/toolchain/compiler.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index ad264ac..a0e7517 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -918,6 +918,7 @@ func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool,
 		cmd = append(cmd, "-Wl,--just-symbols="+elfLib)
 	}
 
+	cmd = append(cmd, "-Wl,-whole-archive")
 	if c.ldResolveCircularDeps {
 		cmd = append(cmd, "-Wl,--start-group")
 		cmd = append(cmd, objList...)
@@ -925,6 +926,7 @@ func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool,
 	} else {
 		cmd = append(cmd, objList...)
 	}
+	cmd = append(cmd, "-Wl,-no-whole-archive")
 
 	if keepSymbols != nil {
 		for _, name := range keepSymbols {