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

Implement the betterC switch like DMD does. #1872

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@LemonBoy
Contributor

LemonBoy commented Nov 9, 2016

Namely, don't emit the ModuleInfo.
Additionally, for the following code we emit less symbols than dmd (28 vs 38) and the resulting executable actually runs as we don't emit any dso section (which explains the former) and no code that fondles with _d_dso_registry (which explains the latter).

module main;

extern(C) __gshared int __dmd_personality_v0;
extern(C) __gshared void* _d_dso_registry;

extern (C) int printf(in char*, ...);

extern (C) int main()
{
    printf("asd\n");
    return 0;
}
@JohanEngelen

This comment has been minimized.

Show comment
Hide comment
@JohanEngelen

JohanEngelen Nov 9, 2016

Member

No tests!

Can you try to include a test that shows that the resulting object file can be linked without druntime?

Member

JohanEngelen commented Nov 9, 2016

No tests!

Can you try to include a test that shows that the resulting object file can be linked without druntime?

@9il

This comment has been minimized.

Show comment
Hide comment
@9il

9il Nov 9, 2016

Other issues:

  1. switch errors
  2. asserts
  3. cast between arrays
  4. Type info
  5. Check that DRuntime is 100% does not required by generated code.

9il commented Nov 9, 2016

Other issues:

  1. switch errors
  2. asserts
  3. cast between arrays
  4. Type info
  5. Check that DRuntime is 100% does not required by generated code.
@LemonBoy

This comment has been minimized.

Show comment
Hide comment
@LemonBoy

LemonBoy Nov 9, 2016

Contributor

IR + Linking test has been attached.
@9il This PR implements betterC a'la dmd, it's not an effort to have a better betterC :) See here for more details.

Contributor

LemonBoy commented Nov 9, 2016

IR + Linking test has been attached.
@9il This PR implements betterC a'la dmd, it's not an effort to have a better betterC :) See here for more details.

@9il

This comment has been minimized.

Show comment
Hide comment
@9il

9il Nov 9, 2016

@9il This PR implements betterC a'la dmd, it's not an effort to have a better betterC :) See here for more details.

OK )

9il commented Nov 9, 2016

@9il This PR implements betterC a'la dmd, it's not an effort to have a better betterC :) See here for more details.

OK )

@kinke

This comment has been minimized.

Show comment
Hide comment
@kinke

kinke Nov 9, 2016

Member

@9il: Is it just that you'd like -betterC to imply -release, getting rid of all assertions, bounds checks, contracts etc.?

Member

kinke commented Nov 9, 2016

@9il: Is it just that you'd like -betterC to imply -release, getting rid of all assertions, bounds checks, contracts etc.?

@klickverbot

Should be okay as a DMD compatibility thing. We might want to sit down and properly discuss our "minimal runtime" to come up with a sensible and flexible design rather than Walter's one-off hack.

Show outdated Hide outdated tests/linking/betterc.d
Implement the betterC switch like DMD does.
Namely, don't emit the ModuleInfo.
@9il

This comment has been minimized.

Show comment
Hide comment
@9il

9il Nov 12, 2016

@9il: Is it just that you'd like -betterC to imply -release, getting rid of all assertions, bounds checks, contracts etc.?

betterC (in my vision) should verify that compiled code does not depend on Druntime. A code can still use some generic code from Phobos. assertions in non release mode should be replaced with inlined checks that use libc to exit from the program.

9il commented Nov 12, 2016

@9il: Is it just that you'd like -betterC to imply -release, getting rid of all assertions, bounds checks, contracts etc.?

betterC (in my vision) should verify that compiled code does not depend on Druntime. A code can still use some generic code from Phobos. assertions in non release mode should be replaced with inlined checks that use libc to exit from the program.

@kinke

This comment has been minimized.

Show comment
Hide comment
@kinke

kinke Nov 13, 2016

Member

Please document the new switch in LDMD's usage output too.

Member

kinke commented Nov 13, 2016

Please document the new switch in LDMD's usage output too.

@klickverbot

This comment has been minimized.

Show comment
Hide comment
@klickverbot

klickverbot Nov 24, 2016

Member

Could you add the description from DMD to -help, please?

-betterC omit generating some runtime information and helper functions

Member

klickverbot commented Nov 24, 2016

Could you add the description from DMD to -help, please?

-betterC omit generating some runtime information and helper functions

@kinke

This comment has been minimized.

Show comment
Hide comment
@kinke

kinke Nov 25, 2016

Member

I amended the LDMD addition and pushed it directly to master (62a2252), so that it can be part of beta 4.

Member

kinke commented Nov 25, 2016

I amended the LDMD addition and pushed it directly to master (62a2252), so that it can be part of beta 4.

@kinke kinke closed this Nov 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment