Author Topic: LLVM Clang 10 no longer supports -Wl,--dll  (Read 2050 times)

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
LLVM Clang 10 no longer supports -Wl,--dll
« on: December 02, 2020, 05:15:10 pm »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #1 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. :)
(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!]

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #2 on: December 03, 2020, 08:37:08 am »
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).

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #3 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.

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #4 on: December 03, 2020, 03:02:33 pm »
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.

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #5 on: December 04, 2020, 10:25:52 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.
« Last Edit: December 04, 2020, 10:29:33 am by gh_origin »

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #6 on: December 04, 2020, 10:30:37 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.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #7 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.
« Last Edit: December 04, 2020, 11:46:00 am by Miguel Gimenez »

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #8 on: December 05, 2020, 03:16:29 pm »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #9 on: December 05, 2020, 04:06:50 pm »
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!]

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #10 on: December 05, 2020, 06:11:01 pm »
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.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #11 on: December 06, 2020, 10:31:25 am »
I repeated the same steps, duplication does not happen  ???. This is the corrected patch.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #12 on: December 06, 2020, 12:44:55 pm »
@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!]

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #13 on: December 06, 2020, 01:24:37 pm »
It is just a proof of concept, if it were a finished patch I would have published it in a ticket.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #14 on: December 06, 2020, 01:56:45 pm »
Probably changing the regex from
Code: [Select]
^(10|11|12) to
Code: [Select]
^([0-9][0-9]+) or
Code: [Select]
^([0-9]{2,}) is enough. I don't have Clang.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #15 on: December 06, 2020, 04:06:41 pm »
Regexes aren't good for this kind of checks.
We need something like https://cmake.org/cmake/help/latest/command/if.html?highlight=version_less
But I suppose it is fine if we drop older versions of clang. :)
(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!]

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #16 on: December 06, 2020, 06:20:07 pm »
EvalXMLCondition() can be easily expanded to evaluate this kind of conditions, adding p.e. "minimum" or "lessthan" verbs.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #17 on: December 06, 2020, 08:01:12 pm »
I know, I don't have the time to do it. If you're interested post patch, if not post a patch which drops the old version, I guess.
(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!]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5267
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #18 on: December 06, 2020, 08:17:39 pm »
I would drop support for old clang, by the way, most recent is clang11.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #19 on: December 06, 2020, 08:21:12 pm »
Yeah, this is easy, but I'm sure this feature would be useful for other places.
(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!]

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 595
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #20 on: December 07, 2020, 01:05:42 pm »
Ticket expanding EvalXMLCondition() published, https://sourceforge.net/p/codeblocks/tickets/1041/

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #21 on: December 12, 2020, 03:34:20 pm »
I don't have Clang.

If you're on Linux, it's easy. If if you're on Windows, you can use my Clang:

https://app.box.com/s/8i0tovgsr354brkcwumus0nzfw1heigg

And sorry everyone, it's my mistake. The Clang version I shared through out the forum is not Clang 10, it's Clang 11 indeed. So I'm not sure whether it's Clang 11 or Clang 10 that dropped supports for -Wl,--dll.

You could get Clang 10 here:

https://app.box.com/s/9gs0idab4ui031043go90s1819uonkop

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #22 on: December 12, 2020, 03:42:11 pm »
But I suppose it is fine if we drop older versions of clang. :)

No. The oldest version of Clang I have seen still being used is Clang 7 (on Linux). I also saw Clang 3.5 still floated around on some organizations. It's not unbelievable, though. Since in my place they only tried to conform to C++11. Newer language standards are not considered. So if old compilers have complete support for C++11, it's no reason to upgrade to new compilers, which most of time caused more problems than it worth.

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #23 on: December 12, 2020, 03:46:18 pm »
I would drop support for old clang, by the way, most recent is clang11.

Most Linux distributions don't ship with latest Clang. The oldest Clang I saw still in use is Clang 7 (I don't remember which distributions, but it seemed to be some kind of LTS of Debian or Ubuntu).

BTW, why no one consider my solution: two sets of XMLs, one for old Clang, one for new Clang? I have posted about that many times on this thread but no one cares.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7056
    • My Best Post
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #24 on: December 12, 2020, 10:37:12 pm »
Two files is twice the effort to maintain as one file.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13007
    • Travis build status
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #25 on: December 13, 2020, 01:06:54 pm »
BTW, why no one consider my solution: two sets of XMLs, one for old Clang, one for new Clang? I have posted about that many times on this thread but no one cares.
Because they easily get out of sync, they are harder to maintain and after all we need this version checking feature anyway. I'll if I can review the Miguel's patch.
(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!]

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: LLVM Clang 10 no longer supports -Wl,--dll
« Reply #26 on: December 13, 2020, 02:32:50 pm »
BTW, why no one consider my solution: two sets of XMLs, one for old Clang, one for new Clang? I have posted about that many times on this thread but no one cares.
Because they easily get out of sync, they are harder to maintain and after all we need this version checking feature anyway. I'll if I can review the Miguel's patch.

I understand. Thanks.