|
|
Created:
12 years, 3 months ago by akumar Modified:
12 years, 3 months ago Reviewers:
CC:
rsc, ality, iant2, golang-dev Visibility:
Public. |
Descriptionlib9: declare __fixargv0 before use in flag.c
The Plan 9 compilers complain about not
having type information for the function,
which sets off type signature problems
during the linking stage.
Patch Set 1 #Patch Set 2 : diff -r 66b0356aa14c https://code.google.com/p/go #Patch Set 3 : diff -r 66b0356aa14c https://code.google.com/p/go #Patch Set 4 : diff -r 43203aa69a8a https://code.google.com/p/go #
Total comments: 2
Patch Set 5 : diff -r 3c2980f1aa44 https://code.google.com/p/go #MessagesTotal messages: 18
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
Sign in to reply to this message.
I was going to include a declaration of __fixargv0() in "include/plan9/libc.h", then thought that it seemed unnecessary to advertise it outside osx. Now it seems plan 9 also needs to be alerted to it. Lucio.
Sign in to reply to this message.
It seems too specific. We're only building one file from lib9 that needs the function -- and only peripherally so. Nor does it seem like this will propagate to other files we'll build, hence a local change here seems sufficient. On 8 January 2013 03:59, Lucio De Re <lucio.dere@gmail.com> wrote: > I was going to include a declaration of __fixargv0() in > "include/plan9/libc.h", then thought that it seemed unnecessary to > advertise it outside osx. Now it seems plan 9 also needs to be > alerted to it. > > Lucio.
Sign in to reply to this message.
Good enough for me, then. Lucio. On 1/8/13, Akshat Kumar <seed@mail.nanosouffle.net> wrote: > It seems too specific. We're only building one file from lib9 > that needs the function -- and only peripherally so. Nor > does it seem like this will propagate to other files we'll build, > hence a local change here seems sufficient. > > > On 8 January 2013 03:59, Lucio De Re <lucio.dere@gmail.com> wrote: >> I was going to include a declaration of __fixargv0() in >> "include/plan9/libc.h", then thought that it seemed unnecessary to >> advertise it outside osx. Now it seems plan 9 also needs to be >> alerted to it. >> >> Lucio. >
Sign in to reply to this message.
Copy and paste the char *argv0; and fixargv0 definitions into flag.c and delete argv0.c entirely. Then flag.c doesn't need to call fixargv0 either.
Sign in to reply to this message.
sysfatal.c uses argv0/fixargv0 as well, iirc. Should perhaps argv0 go into a header file that ought to be included by the sources that need it? On 9 January 2013 11:03, Russ Cox <rsc@golang.org> wrote: > Copy and paste the char *argv0; and fixargv0 definitions into flag.c > and delete argv0.c entirely. > Then flag.c doesn't need to call fixargv0 either.
Sign in to reply to this message.
sysfatal was already working. This is only about the complexities added by flag.c. They go away if we just put argv0.c into flag.c.
Sign in to reply to this message.
Akshat Kumar <seed@mail.nanosouffle.net> once said: > On 9 January 2013 11:03, Russ Cox <rsc@golang.org> wrote: > > Copy and paste the char *argv0; and fixargv0 definitions into flag.c > > and delete argv0.c entirely. > > Then flag.c doesn't need to call fixargv0 either. > > sysfatal.c uses argv0/fixargv0 as well, iirc. Should perhaps argv0 go into a > header file that ought to be included by the sources that need it? argv0 is already defined (with extern) in libc.h Just remove argv0.c and both references to __fixargv0, in sysfatal.c and flag.c. Anthony
Sign in to reply to this message.
PTAL. I've just added __fixargv0 into flag.c and removed argv0.c for now. I can also remove all mentions of __fixargv0 from lib9 if that's preferred. Please let me know.
Sign in to reply to this message.
Yes, please do NOT remove __fixargv0 from lib9. It's there for a reason (there's a comment).
Sign in to reply to this message.
https://codereview.appspot.com/7058054/diff/2002/src/lib9/argv0.c File src/lib9/argv0.c (left): https://codereview.appspot.com/7058054/diff/2002/src/lib9/argv0.c#oldcode32 src/lib9/argv0.c:32: * Mac OS can't deal with files that only declare data. Please copy this comment to the new location. Thank you.
Sign in to reply to this message.
Russ Cox <rsc@golang.org> once said: > Yes, please do NOT remove __fixargv0 from lib9. It's there for a > reason (there's a comment). I read the comment. How is it relevant now that the argv0 declaration is in a file that declares more than data? Anthony
Sign in to reply to this message.
> How is it relevant now that the argv0 declaration is > in a file that declares more than data? The problem is that old linkers (such as Darwin's) do not bring in an object file from an archive just to satisfy a data reference. It only does it to satisfy function references. Referring to __fixargv0 is a way to bring in the object file containing argv0. ARGBEGIN does this; otherwise the link will fail. There is no need for a use of __fixargv0 in flag.c because argv0 is now in the same file. But the definition needs to be there, so that ARGBEGIN can continue to use it. Russ
Sign in to reply to this message.
PTAL. Removed the call to __fixargv0 in flag.c . https://codereview.appspot.com/7058054/diff/2002/src/lib9/argv0.c File src/lib9/argv0.c (left): https://codereview.appspot.com/7058054/diff/2002/src/lib9/argv0.c#oldcode32 src/lib9/argv0.c:32: * Mac OS can't deal with files that only declare data. On 2013/01/10 15:34:14, rsc wrote: > Please copy this comment to the new location. Thank you. Done.
Sign in to reply to this message.
On Fri, Jan 18, 2013 at 12:18 PM, Russ Cox <rsc@golang.org> wrote: >> How is it relevant now that the argv0 declaration is >> in a file that declares more than data? > > The problem is that old linkers (such as Darwin's) do not bring in an > object file from an archive just to satisfy a data reference. It only > does it to satisfy function references. Referring to __fixargv0 is a > way to bring in the object file containing argv0. ARGBEGIN does this; > otherwise the link will fail. There is no need for a use of __fixargv0 > in flag.c because argv0 is now in the same file. But the definition > needs to be there, so that ARGBEGIN can continue to use it. That doesn't sound right. If your object file says "int i;" and the archive says "int i = 2;" then I believe that the Darwin linker doesn't bring in the object from the archive. But if your object file says "extern int i;" then I would expect the linker to pull in the object from the archive. That said, if your object says "extern int i;" and the archive says "int i;", then the object might not be pulled in; different systems have different behaviour for that. Ian
Sign in to reply to this message.
On Fri, Jan 18, 2013 at 7:12 PM, Ian Lance Taylor <iant@google.com> wrote: > That doesn't sound right. If your object file says "int i;" and the > archive says "int i = 2;" then I believe that the Darwin linker > doesn't bring in the object from the archive. But if your object file > says "extern int i;" then I would expect the linker to pull in the > object from the archive. That said, if your object says "extern int > i;" and the archive says "int i;", then the object might not be pulled > in; different systems have different behaviour for that. > Yes, the bss case is the problem I ran into. Russ
Sign in to reply to this message.
LGTM
Sign in to reply to this message.
*** Submitted as https://code.google.com/p/go/source/detail?r=4adf815d56df *** lib9: declare __fixargv0 before use in flag.c The Plan 9 compilers complain about not having type information for the function, which sets off type signature problems during the linking stage. R=rsc, ality, iant CC=golang-dev https://codereview.appspot.com/7058054 Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.
|