Skip to content
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

[dmd-cxx] Add root/system.h header for wrapping system includes #8910

Merged
merged 6 commits into from
Nov 4, 2018

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Nov 4, 2018

Portability of the front-end is not well covered for older targets.

For instance, while Solaris 11 can build just fine, Solaris 10 fails with:

/vol/gcc/src/hg/trunk/local/gcc/d/dmd/arrayop.c: In member function 'virtual void buildArrayIdent(Expression*, OutBuffer*, Expressions*)::BuildArrayIdentVisitor::visit(BinAssignExp*)':
/vol/gcc/src/hg/trunk/local/gcc/d/dmd/arrayop.c:336:29: error: 's' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  336 |             buf->writestring(s);
      |             ~~~~~~~~~~~~~~~~^~~

/vol/gcc/src/hg/trunk/local/gcc/d/dmd/ctfeexpr.c: In function 'int comparePointers(TOK, Expression*, dinteger_t, Expression*, dinteger_t)':
/vol/gcc/src/hg/trunk/local/gcc/d/dmd/ctfeexpr.c:925:13: error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  925 |         int n;
      |     

This is because assert is not marked as noreturn in <assert.h>.

GCC itself provides a couple of headers that wrap around vagaries of the host system to provide a consistent interface for maximum portability.

This patch then moves most front-end system includes into a central place, allowing gdc to override and provide its own copy of this header that includes the gcc headers, or provide gcc-specific portability fixes to the C++ sources.

I need to first check this against gdc to make sure it actually fits well.

@ibuclaw ibuclaw added GDC Gnu D Compiler WIP Work In Progress - not ready for review or pulling C++ Port labels Nov 4, 2018
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "dmd-cxx + dmd#8910"

@ibuclaw ibuclaw changed the title Add root/system.h header for wrapping system includes dmd-cxxAdd root/system.h header for wrapping system includes Nov 4, 2018
@ibuclaw ibuclaw changed the title dmd-cxxAdd root/system.h header for wrapping system includes [dmd-cxx] Add root/system.h header for wrapping system includes Nov 4, 2018
@ibuclaw ibuclaw removed the WIP Work In Progress - not ready for review or pulling label Nov 4, 2018
@ibuclaw
Copy link
Member Author

ibuclaw commented Nov 4, 2018

All malloc and friends are all marked as #pragma GCC poison, so have added ifdefs to forward to the correct xmalloc and friends if compiling gdc.

@ibuclaw
Copy link
Member Author

ibuclaw commented Nov 4, 2018

Rebased.

@ibuclaw ibuclaw force-pushed the dmd-cxx-system branch 2 times, most recently from 03865b9 to a05e5be Compare November 4, 2018 16:49
src/objc_glue.c Outdated Show resolved Hide resolved
@ibuclaw ibuclaw force-pushed the dmd-cxx-system branch 2 times, most recently from 392e8b0 to 371fae3 Compare November 4, 2018 18:17
@ibuclaw
Copy link
Member Author

ibuclaw commented Nov 4, 2018

@jacob-carlborg - I'll just split the latter two, they don't touch any part of the shareable front-end anyway.

Everything else ok?

src/root/dsystem.h Outdated Show resolved Hide resolved
@jacob-carlborg
Copy link
Contributor

Everything else ok?

Looks good, nothing else that I can see.

@ibuclaw ibuclaw merged commit d3ad022 into dlang:dmd-cxx Nov 4, 2018
@ibuclaw ibuclaw deleted the dmd-cxx-system branch November 4, 2018 19:56
kraj pushed a commit to kraj/gcc that referenced this pull request Nov 5, 2018
This introduces a new header that pulls in system includes for use only
in the DMD front-end part of the compiler, fixing up uses of problematic
functions that are prevalent throughout the code.

Commits merged from dmd.

    Fix build of the D frontend on the Hurd and KFreeBSD.
    Initial patch from Matthias Klose.
    dlang/dmd#8893

    Don't care about D/C++ compatibility in C++ port.
    Fixes build error in https://gcc.gnu.org/PR87788
    dlang/dmd#8895

    Allow compiling front-end headers with strict warnings.
    dlang/dmd#8909

    Add root/system.h header for wrapping system includes.
    Fixes https://gcc.gnu.org/PR87865
    dlang/dmd#8910

    Move checkedint to dmd/root.
    dlang/dmd#8912

    Use rmem instead of libc for malloc() and strdup().
    dlang/dmd#8913

    Use align(8) for alignment of UnionExp, fixing several BUS errors
    due to alignment issues on SPARC.
    dlang/dmd#8914

    Don't pass NULL pointer as format parameter to errorSupplemental.
    dlang/dmd#8916

gcc/d/ChangeLog:

2018-11-05  Iain Buclaw  <ibuclaw@gdcproject.org>

	PR d/87865
	* d-system.h: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265780 138bc75d-0d04-0410-961f-82ee72b054a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Port GDC Gnu D Compiler
Projects
None yet
3 participants