-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootstrap-rebuild #37
base: main
Are you sure you want to change the base?
Conversation
Trying to grasp some of this atexit/dso_handle thing - reading https://stackoverflow.com/questions/34308720/where-is-dso-handle-defined and https://itanium-cxx-abi.github.io/cxx-abi/abi.html#dso-dtor-runtime-api . From what I'm getting is that it's perhaps just a matter of defining __dso_handle and a dummy implementation (unless a c++ program), will try that out. |
I was pondering about __dso_handle some more and realized that maybe we could just do what Tendra handles crt0 crt1 and crtn. But that (ff82032) was the last step I had to do into making bootstrap-rebuild work. I do wonder if there's not a better way of handling this. The paths for crtbegin and end are very specific to which gcc and libraries are used. Maybe there should be some sort of a --gcc-toolchain thing like Clang has. |
btw I'm using And this is my system's gcc atm:
But this is my compiler-explorer VM, so for testing purposes, I have most of the compilers the live site has too. |
Hm! I see what you're doing here. But we definitely can't depend on gcc's crt files :) (And yes, the paths will be different for each gcc). We could provide our own. We already do that for some systems - e.g. https://github.com/tendra/tendra/tree/main/osdep/machines/solaris/sparc/src If this is the way to go, I think it would be just the same idea. There also seems to be /usr/lib/i386-linux-gnu/crt1.o |
/usr/lib/i386-linux-gnu/crt1.o comes from libc6-dev:i386, I think this is the right thing to depend on. |
Although it's true that dso_handle is for the C++ ABI, it is required by libc. Here's a tiny discussing between some LLVM people that needed to start implementing it http://llvm.1065342.n5.nabble.com/llvm-dev-Providing-dso-handle-in-LLVM-td109516.html The best thing todo would probably be to put it in TCC as a generation step when __dso_handle is not defined by the user code (as I think you're supposed to be able to implement it yourself if you want alternate behaviour), but I think that's a little complicated. There are some more things aside from __dso_handle though that might be more complicated. Will try it out and include the other symbols that might be needed, and then figure out what they're for. |
The llvm thread there is great, good find. What they're saying about being part of the C++ ABI makes sense. It sounds like providing our own One last question, do you think we should be using /usr/lib/i386-linux-gnu/crt1.o for any other reason? |
Took me a while to realize a lot of code is not actually used or built any more in the project, plus the fact that the code needs to be compiled for multiple architectures.. |
I think the path for /usr/lib/i386-linux-gnu/crt1.o is supposed to be a stable name, isn't it? |
I would assume so. |
Ok, long story short. I have an implementation (that compiles, but segfaults) - but am now realizing the value of __dso_handle needs to be filled with an address. Not sure how I'm going to do that yet, will need to sleep on it. |
Figured out how to fill the address, but it didn't solve the segfault. So I guess I'll be debugging gcc+glibc sources to find out what's going on :'( |
Now fixed, apparently putting the data in .sbss causes issues in 32bit mode or something, so I now put it in .data instead and that seems to work fine. |
Finding out that it's not. /usr/lib32 seems to be the better choice. But this is a native path for x86/64 systems, so it wouldn't work for cross compilation from other platforms I think? I think for now it's better to go for /usr/lib32 instead. Note: Added bootstrap-rebuild to the Github Actions |
So the last step in this is to re-examine the errno problem and test it on other platforms |
I think this is fine - because we'd only be setting this path in an env file under the x32_64 target. We wouldn't set this path for either the native i386 or amd64 (when it exists) targets. |
Yes exactly, agree. I was looking if there might be a better way to query the system about these paths but haven't found any yet
…Sent from my iPhone
On 22 Aug 2020, at 06:11, Katherine ***@***.***> wrote:
But this is a native path for x86/64 systems, so it wouldn't work for cross compilation from other platforms I think?
I think this is fine - because we'd only be setting this path in an env file under the x32_64 target. We wouldn't set this path for either the native i386 or amd64 (when it exists) targets.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Ok then, maybe fixed? I found out there really is no need to refer to Will this cause any issues you think @katef ? |
tspec/base/posix/posix/errno.h.ts
Outdated
@@ -3,8 +3,7 @@ | |||
# | |||
# See doc/copyright/ for the full copyright terms. | |||
|
|||
|
|||
+EXP (extern) int errno ; | |||
+IMPLEMENT "c/c89", "errno.h.ts" ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really interesting. If there's a difference from C89 here, it is likely to be because this version of POSIX did actually specify errno that way. I'll try to check this. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C89 §4.1.3 p2:
and
errno
which expands to a modifiable lvalue/83/ that has typeint
so our C89 definition is correct (of course)
I can't find a copy of the 1988 posix text, IEEE Std 1003.1-1988. But I can find 1990, which does indeed say:
extern int errno;
with no possibility for a macro.
So we cannot +IMPLEMENT
c89's definition here, unfortunately.
Instead I think the proper thing to do, is to mark errno
as __WRONG in the osdep stuff for Linux systems where this is a macro (i.e. all of them).
I also see that the tspec definitions for posix1 +IMPLEMENT
c89, which I now believe to be incorrect.
Perhaps we have the option to provide some compatibility glue in the osdep/ hacked includes, such that our posix
and posix1
TDF tokens are somehow mapped to the underlying libc macro. I'm not sure exactly how to do that, but maybe with PL_TDF.
If we can't do that, this is a great shame. In practice that means we'll need to depend on whatever version of posix
for rebuild did introduce the macro form, not on posix
. Or we find a way to drop the dependency there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(From what I understood from the C definition is that up until C11, it was allowed to be either an assignable thing or a macro. (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1338.htm) While the posix implementations mostly had macros for a very long time.)
However, the problem not so much lies in the definition, but the result of the actual code.
Because +EXP (extern) int errno
causes an actual implementation in the header file that is output (share/tspec/TenDRA/include/posix.api/errno.h
extern int errno ;
), as opposed to the +EXP lvalue int errno;
in c89 that only causes a #pragma (#pragma token EXP lvalue : int : errno # c89.errno.errno
).
So in the case of using the c89 header, it will allow the "actual" errno.h (/usr/include/errno.h
) implementation of the system have ownership of the symbols.
While in the original posix spec, the errno symbol is reimplemented as extern int errno ;
in the resulting errno.h
.
It would be fine if the spec would just output an appropriate pragma.
(I say "implementation" while it's not actual implementation just 'code to say hey I want the symbol here that is defined elsewhere')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From irc:
errno is an lvalue equivalent to extern int, issue 5 made changes to allow for a thread local errno more of which was done in issue 6 with issue 7 completing the task and making it no longer potentially different from c90.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
In IEEE Std 1003.1-2008 (and later editions as well) this is said https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/basedefs/errno.h.html#tag_13_10 : Interesting to note: I realize was different from IEEE Std 1003.1-1988, but TenDRA only has 1 spec implementation. And the way it's implemented in TenDRA seems to be incompatible with most modern unix's in the case of errno. And since technically So that with just posix, you get:
and with strict_posix you get:
|
That's a clever idea, with About errno, i propose a few things:
Especially, the idea of API specs being correct is important for TenDRA; it's what the whole system is based around. Let's do (3) first (and on a separate branch), I think it makes life easier. I'll try to do that myself this evening, if I can. |
I moved out discussion of -Yposix's errno to #57 - because it doesn't help here at all, but it's its own problem regardless. And in #58 I've made the -Yposix flags per file. Sorry if it seems like a lot of fuss, but I'd like to spend a little more time thinking about this. I'm sure we can find a solution somehow that doesn't depend on implementing a whole new tspec API (yet), and also doesn't involve changing what the -Yposix API claims. |
7c8347f
to
46c4502
Compare
At least fixes #7
Although no idea if this is the correct way of course - With these changes there is no reference to
errno
anymore in the symbol table of the object files (well, the 1 I tested with readelf) and now contains a reference to__errno_location
instead.Either way, the original error doesn't occur anymore, but here's the next one: