Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

math: add LDC restritions on usage of x87 extensions#8323

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ljmf00 wants to merge1 commit intodlang:master
base:master
Choose a base branch
Loading
fromljmf00:math-ldc-msvc

Conversation

@ljmf00
Copy link
Member

@ljmf00ljmf00 commentedNov 28, 2021
edited
Loading

This patch adds some restrictions if the library is compiled with LDC compiler
targeting MSVC C runtime.

Partially cherry picked from: ldc-developers/phobos


We need this if we want to go forward with compiling and running the test suite with sanitization and heuristic-based fuzzing.

CC@kinke

@dlang-bot
Copy link
Contributor

Thanks for your pull request,@ljmf00!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, pleasereference a Bugzilla issue or create amanual changelog.

Testing this PR locally

If you don't have alocal development environment setup, you can useDigger to test this PR:

dub run digger -- build"master + phobos#8323"

This patch adds some restrictions if the library is compiled with LDC compilertargeting MSVC C runtime.Partially cherry picked from:https://github.com/ldc-developers/phobosCo-authored-by: Martin Kinkelin <noone@nowhere.com>Signed-off-by: Luís Ferreira <contact@lsferreira.net>
@kinke
Copy link
Contributor

We need this if we want to go forward with compiling and running the test suite with sanitization and heuristic-based fuzzing.

More details please, and why upstreaming some ugliness from LDC is needed here.

This could simpler when moving away fromversion toenum +static if - as x87 can be detected viareal.mant_dig == 64. Not sure what that would mean in terms of compilation speed etc.

@ljmf00
Copy link
MemberAuthor

We need this if we want to go forward with compiling and running the test suite with sanitization and heuristic-based fuzzing.

More details please, and why upstreaming some ugliness from LDC is needed here.

I have talked about this in aforum thread, maybe we can discuss this more in depth, in a separate one.

The idea would be to add the possibility of fuzzing the official standard library or at least making it simpler. We don't have anything set up on Google oss-fuzz and we should start worrying about it. If we want to have a secure implementation, we should not only fuzz the official standard library but also run the test suite against ASAN/UBSAN, and this is a step forward towards that.

This could simpler when moving away fromversion toenum +static if - as x87 can be detected viareal.mant_dig == 64. Not sure what that would mean in terms of compilation speed etc.

Is the behaviour ofreal.mant_dig == 64 specified as such, or implementation-defined? I just ported the code from LDC. Can you clarify what to improve here?CRuntime_Microsoft andAndroid conditions are only specific to LDC, right?

@kinke
Copy link
Contributor

I have talked about this in a forum thread, maybe we can discuss this more in depth, in a separate one.

I'm not sure what the goal is - getting upstream Phobos here to be usable and testable with the current LDC and LDC's druntime version? That's a much bigger task. I've been hesitant to upstream pure LDC specifics; stuff that is also interesting for GDC is a different topic. [And much of that has only recently been enabled, by LDC supporting the GDC/GCC inline asm syntax.]
druntime is particularly tricky due to the tight compiler coupling, and LDC not being in sync with DMD master (and that's utopic - people won't work on a new feature if that requires glue layer changes in multiple compilers to be mergable).

Is the behaviour ofreal.mant_dig == 64 specified as such, or implementation-defined? I just ported the code from LDC. Can you clarify what to improve here?CRuntime_Microsoft andAndroid conditions are only specific to LDC, right?

We currently have 3/4real formats - double, x87 extended, quad and, AFAIK to some very limited extent, 128-bit IBM 'doubledouble'. DMD only supports x87 for all of its targets; LDC and GDC the other ones. In particular, LDC uses 64-bit double precision for MSVC targets, just like the MSVC itself (Clong double is a differently mangleddouble), while DMD sticks with x87. So that explains theCRuntime_Microsoft special case for LDC here. Android is a mess, it uses double for 32-bit x86, and a software quad precisionreal for 64-bit x86 (i.e. the same formats as the ARM architecture with corresponding bitness).

As forreal.mant_dig == 64, x87 is the only format with a 64-bit mantissa at the moment, and I bet it stays that way for a while.

@kinke
Copy link
Contributor

kinke commentedNov 29, 2021
edited
Loading

Can you clarify what to improve here?

In case I misunderstood - the ugliness comes from defining extra helperversions requiring knowledge about thereal formats for Android, MSVC etc., while the x87 check would be a simplestatic if (real_mant.dig == 64). The problem is that it's all version-based at the moment, and you cannot define a version inside a static-if:

staticif (real.mant_dig==64)version = abc;// Error: version `abc` defined after useversion (abc)void foo() {}

So that would require moving from versions to private enums and static-ifs.

@ljmf00
Copy link
MemberAuthor

Can you clarify what to improve here?

In case I misunderstood - the ugliness comes from defining extra helperversions requiring knowledge about thereal formats for Android, MSVC etc., while the x87 check would be a simplestatic if (real_mant.dig == 64). The problem is that it's all version-based at the moment, and you cannot define a version inside a static-if:

staticif (real.mant_dig==64)version = abc;// Error: version `abc` defined after useversion (abc)void foo() {}

So that would require moving from versions to private enums and static-ifs.

Oh, I understand. Is there any compiler issue about it I can reference here, or is this supposed to be the intended behaviour and perhaps a language limitation? If it is a compiler error, I can stale this and try to fix it.

@ljmf00ljmf00 marked this pull request as draftJanuary 7, 2022 13:00
@ljmf00
Copy link
MemberAuthor

ljmf00 commentedJan 7, 2022
edited by 0xEAB
Loading

I marked this as draft due tohttps://issues.dlang.org/show_bug.cgi?id=7386 [edit:dlang/dmd#18407]. After that we should be able to check the mantissa length and set the version without workarounds. Feel free to set this with blocked label, I can't on Phobos.

@LightBenderLightBender added the Review:SalvageThis PR needs work, but we want to keep it and it can be salvaged. labelOct 27, 2024
@LightBender
Copy link
Contributor

This related to:#7668
Adding@thewilsonator

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

Reviewers

@RazvanN7RazvanN7RazvanN7 approved these changes

@ibuclawibuclawAwaiting requested review from ibuclawibuclaw is a code owner

Assignees

No one assigned

Labels

Merge:BlockedMerge:stalledReview:SalvageThis PR needs work, but we want to keep it and it can be salvaged.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@ljmf00@dlang-bot@kinke@LightBender@RazvanN7

[8]ページ先頭

©2009-2025 Movatter.jp