Skip to content
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

GCC 14.1, 13.3 & 12.4 #133

Merged
merged 28 commits into from
Jun 28, 2024
Merged

GCC 14.1, 13.3 & 12.4 #133

merged 28 commits into from
Jun 28, 2024

Conversation

h-vetinari
Copy link
Member

@h-vetinari h-vetinari commented May 7, 2024

Freshly released: 14.1, 13.3, 12.4

@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@h-vetinari
Copy link
Member Author

@conda-forge/ctng-compilers, this is ready for review! Point releases for the maintenance branches should show up towards the end of May.

@h-vetinari
Copy link
Member Author

Ah, we might want to fix #126 here already.

@h-vetinari
Copy link
Member Author

@conda-forge-admin, please rerender

@h-vetinari
Copy link
Member Author

Not sure what's up after #130, but I cannot rerender locally anymore.

  File "E:\miniforge\envs\builder\Lib\site-packages\conda_smithy\feedstock_io.py", line 55, in write_file
    with io.open(filename, "w", encoding="utf-8", newline="\n") as fh:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\[xxx]\\dev\\conda-forge\\ctng-compilers-feedstock\\.ci_support\\linux_aarch64_cross_target_platformlinux-64cross_target_stdlibsysrootcross_target_stdlib_version2.12gcc_maj_ver11gcc_version11.4.0old_tripletx86_64-conda_cos6-linux-gnutripletx86_64-conda-linux-gnu.yaml'

Might be running into path length limitations on windows...

At least the bot still can. :)

@h-vetinari
Copy link
Member Author

@isuruf, unsurprisingly, the mingw patches from #130 fail against GCC 14. What would you like to do here - carry two sets of patches, or build mingw only against GCC 13 (or only against 14)?

@isuruf
Copy link
Member

isuruf commented May 13, 2024

We can carry two sets in recipe/patches/mingw/13 and recipe/patches/mingw/14

@h-vetinari
Copy link
Member Author

@conda-forge/ctng-compilers, this should be ready for review. We might want to link the C++ chrono implementation to a tzdb we supply ourselves (with tzdata; see #126), but for now this is a vanilla upgrade.

@h-vetinari h-vetinari changed the title GCC 14.1 GCC 14.1 & 13.3 May 21, 2024
@h-vetinari
Copy link
Member Author

@conda-forge-admin, please rerender

@h-vetinari
Copy link
Member Author

This now also contains 13.3 & the tzdb fix. PTAL @conda-forge/ctng-compilers :)

@isuruf
Copy link
Member

isuruf commented May 22, 2024

Thanks. 13.3 build fails to apply the patches though.

@isuruf
Copy link
Member

isuruf commented May 22, 2024

For tzdb, can you add a test? Binary prefix relocation usually don't work when the prefix is stored in a std::string.

@h-vetinari
Copy link
Member Author

OK, if you prefer platform-specific implementations over environment variables, that's fine by me. 🤷

@h-vetinari
Copy link
Member Author

OK, if you prefer platform-specific implementations over environment variables, that's fine by me. 🤷

So I tried looking at this, and it's not trivial (from what I can see) to get the path to the library where the function lives. It'd be a bit easier to get the path of the calling executable, but that's useless because it has unknown relationship to $PREFIX. C++20's std::source_location also doesn't help. The best-looking solution I found is the small whereami library (particularly wai_getModulePath), but copying/vendoring that seems like major overkill for something that's solved in a handful of lines when using environment variables...

Or could you tell me how you you envisioned getting a path at a stable/predictable depth in the environment file hierarchy from the C++ side?

@h-vetinari h-vetinari changed the title GCC 14.1 & 13.3 GCC 14.1, 13.3 & 12.4 Jun 20, 2024
@h-vetinari
Copy link
Member Author

See https://github.com/gcc-mirror/gcc/blob/9a76db24e044c8058497051a652cca4228cbc8e9/libsanitizer/sanitizer_common/sanitizer_dl.cpp#L25-L35 for an example.

Thanks. I found the dladdr approach too, but obviously that won't work for windows, where we'd have to use GetModuleFileNameW or similar.

@h-vetinari
Copy link
Member Author

So I implemented something for the relative path approach here, but obviously using dladdr on linux means we need to link libstd++ to libdl. For now I've just hacked this with LDFLAGS (and even that I cannot get to work once something links to libstd++.so itself), but what I'd like to do is use the equivalent of CMakes target_link_libraries for libstd++.so itself.

I think it should be something like AC_LIB_LINKFLAGS, but the makefile(s) in GCC are just indecipherable for me (though I really tried to find where the shared lib gets defined...). Any ideas how/where to do this?

+ tz_dir += "/share/zoneinfo";
+ // std::string constructor deep-copies
+ free(this_lib);
+ return tz_dir.c_str();
Copy link
Member

@mbargull mbargull Jun 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pointer outlives the memory it points to when it is being returned.
We should return a pointer to statically allocated memory instead, I think.
Additionally, the allocations from this_lib and tz_dir are not really needed.
For this_lib you can just continue to use resolved instead.
And if you allocate buffer with size PATH_MAX + sizeof(TO_PREFIX "/share/zoneinfo") you can append the suffix directly to resolved in buffer's memory then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! For now, I'm just trying to get something working1. Improving the implementation can be done afterwards (even if it happens as part of this PR after all).

Footnotes

  1. despite trying to keep the implementation minimal/simple, I remain strongly doubtful that the trade-off of all that complexity just for avoiding a corner³ case compared to the env var approach is beneficial.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improving the implementation can be done afterwards (even if it happens as part of this PR after all).

This was just me seeing a use-after-free error, so wanted to make sure that we don't include it in lower level libs.

I remain strongly doubtful that the trade-off of all that complexity just for avoiding a corner case compared to the env var approach is beneficial.

<chrono> use and in conjunction with hitting tzdb absence/differences is a corner case as of now, yes.
Not having CONDA_PREFIX set or set to a different path is really common, though (e.g., think about conda-build: we have a host and build environment -- only packages from one of them can use CONDA_PREFIX at runtime).
There are plethora of ways things can go wrong with reliance on env vars (and with reliance on activation scripts even more so) -- it's too brittle for us to rely on in lower level libs.
(Wcan chat about why/where there are so many problems with that if things are unclear, if you want.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having CONDA_PREFIX set or set to a different path is really common, though (e.g., think about conda-build: we have a host and build environment -- only packages from one of them can use CONDA_PREFIX at runtime).

It's easy to probe all of CONDA_PREFIX resp. PREFIX / BUILD_PREFIX (if CONDA_BUILD is set), and even without anything, we'd find the system tzdb.

So a bug related to this requires: no valid env vars (which is not the case in any of our build infra or user envs), an out-of-date system tzdb (<-- user's fault/problem IMO), stumbling over anything that actually changed in the tzdb compared to an older system tzdb (almost nothing changes unless a country changes its laws about timezones), and using a timestamp just around the summer-/wintertime change. It's so extremely narrow a problem that I don't think the implementation effort for relative paths is anywhere near justified.

In any case, I'm trying to follow your and Isuru's preference. Help with the implementation is appreciated (so thanks for pointing out the bug) - I didn't expect it to be ready yet either, hence the debugging skips here. Right now I'm not even hitting the UAF due to the problems related to linking libdl, so that's the first thing to tackle.

@h-vetinari
Copy link
Member Author

I'm going to go with this for now:

@isuruf: Let's remove the patch and merge and figure out tzdb stuff later.

I'll put up another PR with the WIP patch, and we can work from there, without indefinitely blocking the version upgrade.

@h-vetinari
Copy link
Member Author

Any objections to merging @isuruf?

@@ -30,7 +30,7 @@ package:
version: {{ version }}

source:
- url: https://sourceware.org/pub/gcc/releases/gcc-{{ version }}/gcc-{{ version }}.tar.gz
- url: https://ftp.gnu.org/gnu/gcc/gcc-{{ version }}/gcc-{{ version }}.tar.gz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, 12.4 wasn't available on the ftp server shortly after release, and the announcement made it seem like that won't happen (also my understanding of sourceware was that it's much closer to GCC than third-party). Just for context why I changed that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks. I didn't see the FSF affiliation.

@isuruf isuruf merged commit da577d5 into conda-forge:main Jun 28, 2024
19 of 64 checks passed
@h-vetinari h-vetinari deleted the 14 branch June 28, 2024 00:55
@h-vetinari
Copy link
Member Author

@isuruf, AFAICT we have a bootstrapping problem here:

Could not solve for environment specs
The following package could not be installed
└─ gcc_impl_win-64 13.3.0.*  is not installable because it requires
   └─ libgcc-devel_win-64 13.3.0 h5200ebd_100, which requires
      └─ __win, which is missing on the system.

libgcc-devel_win-64 is being built in that same job, but gcc (the output where things fail) wasn't part of the first mingw builds, so by the time it was enabled (e60f041) we already had some libgcc builds to work with.

I guess the subdir confusion is coming from a missing build: environment (even if it's empty, like it is for gcc_impl).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants