Repository navigation
Remove dependency of System.Globalization.Native.so on specific ICU version - #7773
Conversation
|
@stephentoub, @ellismg can you take a look please? |
|
With this change, I was able to use dotnet cli package for Ubuntu 14.04 (replacing only the System.Globalization.Native.so with my version) and run |
| char libicui18nName[64]; | ||
|
|
||
| GetVersionedLibFileName("libicuuc.so", majorVer, minorVer, subVer, libicuucName); | ||
| GetVersionedLibFileName("libicui18n.so", majorVer, minorVer, subVer, libicui18nName); |
There was a problem hiding this comment.
Nit: I realize this can't happen with the values currently chosen, but if the size of libicuucName/libicui18nName were to be decreased and the values of the max major/minor versions were to be increased, it's possible we could find ourselves overflowing these buffers. Consider putting some length checks in place to ensure that never happens with future refactorings.
There was a problem hiding this comment.
The size is safe for these two libraries even with the max int values for each of the versions. The max combined size of the versions is 33 characters (3 dots and 10 digits max for each int).
But I agree that a size check never hurts.
| } | ||
|
|
||
| return false; | ||
| } |
There was a problem hiding this comment.
In the worst case, have you looked to see what kind of startup impact this has with lots of dlopen failures?
There was a problem hiding this comment.
I have tried to swap the order of the loops to start with the version that tries to go with the three components of the version, which fails to find anything on my Ubuntu. The whole initialization took 45ms in that case on my machine. Without this flip of order, it takes 8ms.
|
I can see from the CI results that I have an issue on FreeBSD due to a need to use HAVE_SET_MAX_VARIABLE define to pick ucol_setMaxVariable or ucol_setVariableTop and there is some issue on ARM where it looks like the symbol versioning is different (maybe it is not adding versions to ICU symbols at all?). |
| return libicuuc != nullptr; | ||
| } | ||
|
|
||
| // Select libraries using the version override specified by the CLR_ICU_VERSION_OVERRIDE |
There was a problem hiding this comment.
Should we use "COMPlus" or some variant instead, for symmetry with the other tuning values?
There was a problem hiding this comment.
COMPlus is used only for CoreCLR options, so I didn't want to cause confusion by using it for CoreFX components options. Besides that, we use CORE_LIBRARIES and CORECLR_SERVER_GC for Unix corerun / coreconsole, PAL_xxx for PAL stuff.
I am open to any name suggestions, the currrent name was just the first idea I got.
There was a problem hiding this comment.
That's a rational explanation. CLR_ICU_VERSION_OVERRIDE sounds good to me.
| #include "errors.h" | ||
|
|
||
| #ifndef FEATURE_FIXED_ICU_VERSION | ||
| // The System.Globalization.Native.so is built in mode that allows it to find the local |
There was a problem hiding this comment.
Perhaps a better comment would be that we want to support versions of ICU where UDAT_STANDALONE_SHORTER_WEEKDAYS was not yet defined?
There was a problem hiding this comment.
It is half of the truth. The main problem is really the fact that it is not part of the stable APIs, so even if we wanted to support only newer versions of ICU that have that API, we should not do that unless it became part of the stable API.
There was a problem hiding this comment.
But I agree that the comment is somehow convoluted, I'll try to clean it a bit and integrate both points in it.
55ebb92 to
7f9fe57
Compare
|
@dotnet-bot test this please |
a4c63d8 to
c544ab5
Compare
|
@ellismg, @stephentoub I've reflected your feedback and fixed the ARM and FreeBSD issues, can you please take another look? |
|
@ellismg, @stephentoub I actually wonder if the MaxICUVersion where I start scanning should be lower than the very conservative 99. The more versions we scan before we find one, the longer time it takes. As I've mentioned, the time even with the starting version 99 and the case we need to scan lib names with all three version components, the whole initialization takes about 45 ms on my native Linux box, which is not much. But still, I can see that since 2012, the ICU had about two major version releases a year, so if this trend continues, the current code is ready for the next 20 years of releases, which sounds like an overkill. |
I would hate for us to have to patch the LTS trains (i.e the major version releases) in order to bump this number, so we should hopefully always have two years of ICU growth baked in, and then just move things along? Would we be comfortable with starting the cap at something like 70? |
| // only use stable APIs and the UDAT_STANDALONE_SHORTER_WEEKDAYS doesn't belong to those. | ||
| // We also want to support ICU versions where the UDAT_STANDALONE_SHORTER_WEEKDAYS was not | ||
| // defined yet. | ||
| #undef HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS |
There was a problem hiding this comment.
I think we also need to undef HAVE_SET_MAX_VARIABLE here. Is there some way we can just make changes in the configure step to make all the checks on FEATURE_FIXED_ICU_VERSION being set?
There was a problem hiding this comment.
I would prefer to keep the configure step agnostic of what we are building and just providing information of what is available during the build.
Now this HAVE_SET_MAX_VARIABLE is different from the HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS. If you have ICU that already has the ucol_setMaxVariable at the build time and you'd try to use the old ucol_setVariableTop, the compilation will fail with warning on the ucol_setVariableTop being deprecated.
It is actually interesting what does it really mean for a stable api like this to be deprecated. Based on what they say on the stable APIs, it should still exist in the future versions of the library, so I assume it won't be removed in the future.
I am actually starting to think that I should change the minimum major version number of ICU that we support to be the version of ICU we are building against. That would mean that when we want to build a version of System.Globalization.Native.so that would work on a set of supported distros, we would build it on a distro with the oldest dependencies from all the distros from the set. That's what we actually need to do for glibc as well to make sure we don't reference a newer version of a function from glibc - from time to time, new versions of the same functions are added to glibc while the older ones remain.
If we did it this way, then we would keep the HAVE_SET_MAX_VARIABLE usage as I have it now.
Does it make sense?
There was a problem hiding this comment.
Does it make sense?
I think so. However, if we make these changes, we should be able to remove the hack around HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS as well, correct. When building in this new mode, we assert that the code will run on any version at least as high at the version you compiled on. Since we only use stable stuff, we can use our configure tests. Right?
There was a problem hiding this comment.
I guess my question is why HAVE_SET_MAX_VARIABLE and HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS have to be treated differently if we make the changes you describe. UDAT_STANDALONE_SHORTER_WEEKDAYS was not present in ICU 50 (it went stable in ICU 51) and so the configuration test will fail. If we try to take version of System.Globalization.Native.so built on ICU 51 and run it on a platform with ICU 50 or earlier, our loop to find a library to dlopen would fail, because we stop searching at U_ICU_VERSION_MAJOR_NUM right?
There was a problem hiding this comment.
I thought I have tried to build it with ICU 52 and the U_HIDE_DRAFT_API defined and the UDAT_STANDALONE_SHORTER_WEEKDAYS was not present, so I have assumed it is still not stable in 52. Now I have tried again and it builds fine, so I think I was just daydreaming.
But with this new idea of using the U_ICU_VERSION_MAJOR_NUM as the minimum major version, it seems HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS should be handled the same way as the other one as you say.
Regarding
If we try to take version of System.Globalization.Native.so built on ICU 51 and run it on a platform with ICU 50 or earlier, our loop to find a library to dlopen would fail, because we stop searching at U_ICU_VERSION_MAJOR_NUM right?
Yes, that would be the case.
There was a problem hiding this comment.
Yes, that would be the case.
Okay, I like the plan.
| static void* libicui18n = nullptr; | ||
|
|
||
| // Version ranges to search for each of the three version components | ||
| static const int MinICUVersion = 50; |
There was a problem hiding this comment.
Is there a way we can assert at build time that this is greater than or equal to U_ICU_VERSION_MAJOR_NUM, as a sanity check?
There was a problem hiding this comment.
Reading your comment above, it sounds like you may just want to change this to U_ICU_VERSION_MAJOR_NUM anyway :-).
There was a problem hiding this comment.
Actually, look at my other comment. I would prefer making it equal to U_ICU_VERSION_MAJOR_NUM.
|
@ellismg I've made the change we have discussed. |
| // | ||
|
|
||
| // Enable calling ICU functions through shims to enable support for | ||
| // multiple versions of ICU if the FEATURE_ICU_VERSION_RESILIENT is |
There was a problem hiding this comment.
NIT: I think FEATURE_ICU_VERSION_RESILIENT is now spelled FEATURE_FIXED_ICU_VERSION? There's another reference to this in a comment at the end of the file.
|
One small NIT, but it LGTM otherwise. Thanks for making the changes here, Jan. |
…ersion This change adds a shim layer between the ICU libraries and the code in System.Globalization.Native.so that automatically picks a version of the ICU libraries that is installed on the current machine. This enables usage of the same System.Globalization.Native.so on various Linux distributions and their versions. The minimal ICU version supported is U_ICU_VERSION_MAJOR_NUM, the maximum supported is the minimum plus 20.
|
@ellismg thanks for spotting the old feature name in the comment. |
5440a38 to
f8ca90f
Compare
|
@dotnet-bot Windows_NT x64 Formatting |
there was a change done by the PR dotnet#7773 which removed the dependency on ICU version. and there is another PR dotnet#7811 which used more ICU APIs not listed in the shim. the change here is to add these APIs to the shim
This change adds a shim layer between the ICU libraries and the code in
System.Globalization.Native.so that automatically picks a version of the ICU
libraries that is installed on the current machine. This enables usage of
the same System.Globalization.Native.so on various Linux distributions and
their versions. The minimal ICU version supported is the one the System.Globalization.Native.so is built with.