News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

LLVM Clang 10 no longer supports -Wl,--dll

Started by gh_origin, December 02, 2020, 05:15:10 PM

Previous topic - Next topic

gh_origin

I tried to compile a DLL. The compiler produced many object files but failed to link them because it said it doesn't understand the option --dll. I edit the options_clang.xml and remove -Wl,--dll from the value of LinkDynamic so it's basically like this:

<Command name="LinkDynamic"
                 value="$linker -shared -Wl,--output-def=$def_output -Wl,--out-implib=$static_output $libdirs $link_objects $link_resobjects -o $exe_output $link_options libs"/>

After that it could link the object files and produce a DLL.

oBFusCATed

There is a way to check the version of the compiler and make this conditional. After that post a patch and we might include it. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

gh_origin

Quote from: oBFusCATed on December 02, 2020, 08:56:01 PM
There is a way to check the version of the compiler and make this conditional. After that post a patch and we might include it. :)

How to write conditional in XML? The fastest hack I could think of is creating another XMLs for newer Clang, e.g: compiler_clang_old.xml, options_clang_old.xml (still have -Wl,--dll), compiler_clang_new.xml, options_clang_new.xml (no longer have -Wl,--dll). The checking for compiler version part just let the users do it by manually select their compiler (clang_old or clang_new).

Miguel Gimenez


gh_origin

Quote from: Miguel Gimenez on December 03, 2020, 09:13:11 AM
You can use my patch for GCC in ticket 1006 (https://sourceforge.net/p/codeblocks/tickets/1006/) as a reference.

I will try if I could do it after I cleared my confusion between the Dynamic Link Library project type and Shared Library project type. You could see my thread asked about that.

gh_origin

#5
Quote from: Miguel Gimenez on December 03, 2020, 09:13:11 AM
You can use my patch for GCC in ticket 1006 (https://sourceforge.net/p/codeblocks/tickets/1006/) as a reference.

Sorry, I still have no idea even when have read your code many times. I don't know how to adapt your code for this situation.

The situation between yours and mine seemed to completely different. "-std=" kind of options are to plug into compiler (not really needed). But the -Wl,--dll kind of options are part of the linker command itself. In no possible way I found it's able for me to do the same as with the former kind of options.

It seemed can't help with this problem.

gh_origin

Quote from: gh_origin on December 03, 2020, 08:37:08 AM
The fastest hack I could think of is creating another XMLs for newer Clang, e.g: compiler_clang_old.xml, options_clang_old.xml (still have -Wl,--dll), compiler_clang_new.xml, options_clang_new.xml (no longer have -Wl,--dll). The checking for compiler version part just let the users do it by manually select their compiler (clang_old or clang_new).

I still think this is the optimal solution.

Miguel Gimenez

#7
It does not look too difficult, here you have a possible patch (untested, I don't have Clang).

I have attached also the complete file (renamed from xml to txt) so you can paste it directly in the compilers directory.

gh_origin

Quote from: Miguel Gimenez on December 04, 2020, 11:31:30 AM
It does not look too difficult, here you have a possible patch (untested, I don't have Clang).

I have attached also the complete file (renamed from xml to txt) so you can paste it directly in the compilers directory.

Perhaps it's because I'm stupid. You know, if I'm more intelligent, I'm now would not be a secondary school teacher. Maybe I'm teaching in college  ;)

You are right when provided a ready working file, as I really don't know how to apply the patch. BTW, your XML has one minor problem. It has two "<?xml version="1.0"?>:" line so CodeBlocks doesn't consider it as valid so it said there is no options_clang.xml and just quit. Deleting the duplicated line and everything work as expected. Thank you for being patient with me.

oBFusCATed

Patches are applied with the patch utility or something similar.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Miguel Gimenez

I don't know why the line got duplicated, possibly it is BOM-related. I edited it with Notepad++, and only changed the options part.

Miguel Gimenez

I repeated the same steps, duplication does not happen  ???. This is the corrected patch.

oBFusCATed

@Miguel Gimenez This patch is not good. It doesn't handle future versions and requires constant changes with every new version of clang. You need to somehow make a test that does '<10' or something similar. But unfortunately Compiler::EvalXMLCondition doesn't seem to support such conditions. :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Miguel Gimenez

It is just a proof of concept, if it were a finished patch I would have published it in a ticket.

Miguel Gimenez

Probably changing the regex from ^(10|11|12) to ^([0-9][0-9]+) or ^([0-9]{2,}) is enough. I don't have Clang.