www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19243] New: [REG 2.081] Can no longer override pragma(lib)


          Issue ID: 19243
           Summary: [REG 2.081] Can no longer override pragma(lib) with -L
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

Consider a program written against the OpenSSL 1.0 API, e.g.:

////////////////////////////////// test.d //////////////////////////////////
pragma(lib, "ssl");
pragma(lib, "crypto");

extern (C)
    struct SSL_METHOD;
    struct SSL_CTX;

    void SSL_load_error_strings();
    void SSL_library_init();
    void OPENSSL_add_all_algorithms_noconf();
    alias OpenSSL_add_all_algorithms = OPENSSL_add_all_algorithms_noconf;
    SSL_METHOD* SSLv23_client_method();

shared static this()

T sslEnforce(T)(T v, string message)
    if (v) return v;
    throw new Exception(message);

    auto method = SSLv23_client_method().sslEnforce("SSLv23_client_method");

pragma(lib) allows it to be linked to the necessary libraries automatically,
without having to specify them on the compiler/linker command line.

However, on some systems, the default libraries (i.e. e.g. /usr/lib/libssl.so)
might be the wrong version. We can override them with -L switches, i.e.:

$ dmd -main -unittest -g -L/usr/lib/libssl.so.1.0.0
-L/usr/lib/libcrypto.so.1.0.0 -run test.d

This no longer works in 2.081. The change introduced by the PR linked below
changes how linker arguments on the compiler's command line are processed,
breaking existing build scripts.

The example above can be reproduced on Arch Linux with the openssl-1.0 package
installed. The dmd command above succeeds with DMD 2.080 but fails with 2.081.

Introduced in https://github.com/dlang/dmd/pull/8172

Sep 13 2018