-
Notifications
You must be signed in to change notification settings - Fork 173
Problems with gconstructor.h and source FMU's in MSVC #4576
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
Comments
@KarlWernersson I understand that it might be a problem if a source code FMU contains the same source files as the simulation environment. I want to create a minimal example, indpendent of FMU or Dymola. Is it as simple as building an executable which compiles ModelicaRandom.c and links ModelicaExternalc.lib where
|
…ols issue in test code
@KarlWernersson Have a look at my branch beutlich:issue4576 where I first added some test case demonstrating the MSVC build error on duplicated symbols (following the TDD approach) and afterwards applied the name mangling following your proposal. Let me know if it works for you if you export FMU and re-import FMU from this branch. |
@KarlWernersson will look at that next week. However, I realized that we have to be even more careful regarding this, as there are two interrelated problems:
The second issue ( related to modelica-3rdparty/ExternData#53 ) is that if you have a library (like ExternData) using the existing (Obviously those libraries should be upgraded as well at some time.) |
Yes, it might be better to have a new file and new macros to avoid any potential compatibility problems. I updated my branch accordingly. |
Will this mean that older versions of ExtrernData will not be compatible with Dymola 2025x R1 in which these changes have been made? |
Hi @GarronFish we will try to avoid that. |
Did you find the time to inspect my proposed and test changes? I also wonder if this change is relevant for upcoming MSL v4.1.0? |
@beutlich |
@KarlWernersson Any news on this? |
@beutlich Hi sorry for they delay. Your solution looks good, i have ported it already to Dymola, initial tests are OK, but more thorough tests will run over the night. |
@KarlWernersson any results from your further batch of tests? |
@beutlich how do we proceed? Shall something be merged on master? |
* Introduce and apply name mangling to avoid MSVC duplicated symbols issue * Bump version by renaming file and macros
I am unsure if this is a library issue or a general MSL issue with re-imported FMUs. I am unsure what @KarlWernersson means by "has been ported and will be included in Dymola 2025x Refresh 1". If it means that Dymola no longer distributes an officially released MSL (like other tool-vendors do), I wonder if I am still able to load my MSL from repository. Nevertheless, I created #4620 from the proposed changes. It does not harm at all to merge it (provided that no tool vendor or library vendor was ever depending on the existence of gconstructor.h). |
* Introduce and apply name mangling to avoid MSVC duplicated symbols issue * Bump version by renaming file and macros
* Introduce and apply name mangling to avoid MSVC duplicated symbols issue * Bump version by renaming file and macros
Hi
When trying to compile a Dymola source FMU together with a Dymola simulation and then link them there are many identical functions that causes link problems. A way to simply solve this is by making sure things are static declared.
Now for the gconstructor for MSVC the constructor has the following hack to force some function calls before main
#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
As some of these functions aren't static declared i get to problems when both the FMU and the dymola simuation uses modelicaInternal.c
I tried to modify the hack to make it static but it don't seem to work and i cant say I am an expert in this low level mscv hacking.
My workaround was to copy the name pasting of ModelIdentifier from FMI as this for us is only an issue for FMU's for us.
added to gconstructor _MSC_VER >=1500 defined
non _MSC_VER
#define G_FullName(name) name
and then later in ModelicaRandom,c ModelicaInternal.c, modelicaStandardTables.c I modified the use of G_DEFINE_CONSTRUCTOR by inserting the G_FullName macro
If anyone has a better solution i am al ears, otherwise i am happy to make a pull request
The text was updated successfully, but these errors were encountered: