Hosted GCC Cross-Compiler: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
m Remove extra blank line
Barry (talk | contribs)
Updated for a later version of GCC
Line 25: Line 25:


* <tt>sys/types.h</tt>: <tt>pid_t</tt>.
* <tt>sys/types.h</tt>: <tt>pid_t</tt>.
* <tt>stdlib.h</tt>: <tt>atexit()</tt>, <tt>atoi()</tt>, <tt>getenv()</tt>.
* <tt>stdlib.h</tt>: <tt>atexit()</tt>, <tt>atoi()</tt>, <tt>getenv()</tt>, <tt>malloc()</tt>, <tt>calloc()</tt>, <tt>abs()</tt>.
* <tt>stdio.h</tt>: <tt>size_t</tt>, <tt>SEEK_SET</tt>, <tt>fclose()</tt>, <tt>fopen()</tt>, <tt>fread()</tt>, <tt>fseek()</tt>, <tt>ftell()</tt>, <tt>fwrite()</tt>, <tt>setbuf()</tt>, <tt>vfprintf()</tt>.
* <tt>stdio.h</tt>: <tt>size_t</tt>, <tt>SEEK_SET</tt>, <tt>fclose()</tt>, <tt>fopen()</tt>, <tt>fread()</tt>, <tt>fseek()</tt>, <tt>ftell()</tt>, <tt>fwrite()</tt>, <tt>setbuf()</tt>, <tt>vfprintf()</tt>, <tt>sprintf()</tt>.
* <tt>string.h</tt>: <tt>strcpy()</tt>.
* <tt>string.h</tt>: <tt>strcpy()</tt>, <tt>strcat()</tt>, <tt>strchr()</tt>.
* <tt>unistd.h</tt>: <tt>pid_t</tt>, <tt>fork()</tt>, <tt>execv()</tt>, <tt>execve()</tt>, <tt>execvp()</tt>.
* <tt>unistd.h</tt>: <tt>pid_t</tt>, <tt>intptr_t</tt>, <tt>fork()</tt>, <tt>execv()</tt>, <tt>execve()</tt>, <tt>execvp()</tt>, <tt>getpid()</tt>.


Note how these are statically linked libraries and are not linked. It will do to simply add function prototypes with no implementation (or better yet, a stub implementation, or a real one) and no linker errors will happen unless the relevant parts of libgcc or libgcov are needed. Note how these are just the minimum requirements to get by without any implicit-function-declaration issues; the code is able to use more standard library features if available.
Note how these are statically linked libraries and are not linked. It will do to simply add function prototypes with no implementation (or better yet, a stub implementation, or a real one) and no linker errors will happen unless the relevant parts of libgcc or libgcov are needed. Note how these are just the minimum requirements to get by without any implicit-function-declaration issues; the code is able to use more standard library features if available.


For the record and convenience, [https://gist.github.com/sortie/9a64aa532052e2137f05f5324a75b474 here are minimal headers] that satisfies the requirements.
For the record and convenience, [https://gist.github.com/sortie/9a64aa532052e2137f05f5324a75b474 here are minimal headers] that satisfies the requirements. (UPDATE: This repo is outdated, and GCC will still warn you about missing declarations. Just add them as you see them, it's only a few, and you can copy from your system headers.)


== Sysroot Headers ==
== Sysroot Headers ==
Line 92: Line 92:


<source lang="bash">
<source lang="bash">
./../../../gcc-7.2.0/libstdc++-v3/libsupc++/new_opa.cc:62:1: error: ‘void* aligned_alloc(std::size_t, std::size_t)’ was declared ‘extern’ and later ‘static’ [-fpermissive]
./../../../gcc-11.3.0/libstdc++-v3/libsupc++/new_opa.cc:62:1: error: ‘void* aligned_alloc(std::size_t, std::size_t)’ was declared ‘extern’ and later ‘static’ [-fpermissive]
aligned_alloc (std::size_t al, std::size_t sz)
aligned_alloc (std::size_t al, std::size_t sz)
</source>
</source>