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

Fix issue 19329 pragms(lib) and pragma(linkerDirective) can emit dupl… #12308

Closed
wants to merge 1 commit into from

Conversation

thewilsonator
Copy link
Contributor

…icate entries to the object

Not sure how to write a test for this

@dlang-bot
Copy link
Contributor

dlang-bot commented Mar 25, 2021

Thanks for your pull request and interest in making D better, @thewilsonator! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

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.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

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

dub run digger -- build "master + dmd#12308"

@thewilsonator
Copy link
Contributor Author

this should be good to go mod tests, cc @TurkeyMan

@thewilsonator thewilsonator force-pushed the issue-19329 branch 2 times, most recently from aba2d2f to 2522f0f Compare March 29, 2021 07:22
@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Apr 2, 2021

Not sure how to write a test for this

Maybe create a dshell test that builds a library and adds it multiple times using pragma(...)?

@RazvanN7
Copy link
Contributor

RazvanN7 commented Apr 8, 2021

ping @thewilsonator

@MoonlightSentinel
Copy link
Contributor

You could also try to override the linker to check the arguments (as done for dshell/test6952.d):

E.g.

enum LIB = "uniqueLibraryName1234";

version (AS_TEST)
{
    // Insert actual test here
    pragma(lib, LIB);
   //  ...
}
else:

import std.algorithm;
import std.stdio;
import dshell;

int main(const string[] args)
{
    // Cannot easily override the linker on windows
    if (OS == "windows")
        return DISABLED;

    // Invoked as CC?
    if (args.length > 1)
    {
        const num = args.count!(a => a.canFind(LIB));

        if (num == 1)
            return 0;

        writeln();
        writeln(num ? "Passed `LIB` multiple times!" : "Didn't pass `LIB` at all!");
        writeln(args);
        writeln();
        return 1;
    }

    // Recompile this file as the test defined above
    string cmd = "$DMD -m$MODEL -version=AS_TEST -od=$OUTPUT_BASE " ~ __FILE_FULL_PATH__;
    string[string] env = [
        "DFLAGS": "",
        "CC": args[0],
    ];
    return tryRun(parseCommand(cmd), stdout, stderr, env);
}

@RazvanN7
Copy link
Contributor

ping @thewilsonator

@RazvanN7
Copy link
Contributor

@thewilsonator please add the test suggested by @MoonlightSentinel so that we can get this in.

@RazvanN7
Copy link
Contributor

@ping @thewilsonator

@thewilsonator
Copy link
Contributor Author

#16849

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

Successfully merging this pull request may close these issues.

4 participants