mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: "Érico Rolim" <ericonr@disroot.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] Makefile: fix src/api compilation.
Date: Fri, 24 Jul 2020 16:33:56 +0200	[thread overview]
Message-ID: <20200724143356.GA879655@port70.net> (raw)
In-Reply-To: <20200723034433.24004-1-ericonr@disroot.org>

* Érico Rolim <ericonr@disroot.org> [2020-07-23 00:44:33 -0300]:
> Adding all .o files in src/api to the api/main.OBJ variable led to them
> being included twice when linking api/main.exe, which failed with a
> double definition of the main() function. This can be tested by removing
> the failing definitions from unistdc.c and running make.

thanks.

> ---
> 
> This is a patch for libc-test.
> 
>  Makefile | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 86b6ff5..683c850 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -113,7 +113,6 @@ $(B)/common/mtest.o: src/common/mtest.h
>  $(math.OBJS): src/common/mtest.h
>  
>  $(B)/api/main.exe: $(api.OBJS)
> -api/main.OBJS:=$(api.OBJS)
>  $(api.OBJS):$(B)/common/options.h
>  $(api.OBJS):CFLAGS+=-pedantic-errors -Werror -Wno-unused -D_XOPEN_SOURCE=700

this is not the right fix,

the problem is that api/main.o is duplicated:
once because of the %.exe: %.o rule and once
in the api/main.OBJS.

but all other api/*.o files are not duplicated
and should be linked (so we link test all
referenced symbols not just include header test).

i'm considering doing

 $(B)/%.exe: $(B)/%.o
-       $(CC) $(LDFLAGS) $($*.LDFLAGS) -o $@ $< $($*.OBJS) $(LDLIBS) $($*.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err
+       $(CC) $(LDFLAGS) $($*.LDFLAGS) -o $@ $(sort $< $($*.OBJS)) $(LDLIBS) $($*.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err

(note: the make sort function removes duplicates)

  reply	other threads:[~2020-07-24 14:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23  3:44 Érico Rolim
2020-07-24 14:33 ` Szabolcs Nagy [this message]
2020-07-24 18:23   ` Érico Nogueira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200724143356.GA879655@port70.net \
    --to=nsz@port70.net \
    --cc=ericonr@disroot.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).