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

Search libgdiplus in /usr/local/lib on macOS #41503

Merged
merged 1 commit into from
Sep 1, 2020
Merged

Search libgdiplus in /usr/local/lib on macOS #41503

merged 1 commit into from
Sep 1, 2020

Conversation

am11
Copy link
Member

@am11 am11 commented Aug 28, 2020

With Apple's Hardened Runtime, /usr/local/lib is not searched for
dlopen(3) calls.

Today, some brew packages, such as mono-libgdiplus (used by
System.Drawing) are installed in /usr/local/lib. This causes
DllNotFoundException and user is supposed to either:

  1. manually create a symlink to /usr/local/lib/libgdiplus.dylib.
  2. export LD_LIBRARY_PATH, DYLD_LIBRARY_PATH or
    DYLD_FALLBACK_LIBRARY_PATH to /usr/local/lib.
  3. remove signature from dotnet binary:
    sudo codesign --remove-signature $(command -v dotnet)

This patch adds a fallback lookup for libgdiplus.dylib, to avoid
workaround on macOS (as it is done for Linux: libgdiplus.so falls
back to libgdiplus.so.0).

Also removed LIBSEARCHPATH which is unused since 8d5e610.

cc @janvorli

With Apple's Hardened Runtime, `/usr/local/lib` is not searched for
`dlopen(3)` calls.

Today, some brew packages, such as `mono-libgdiplus` (used by
System.Drawing) are installed in `/usr/local/lib`. This causes
`DllNotFoundException` and user is supposed to either:

1. manually create a symlink to `/usr/local/lib/libgdiplus.dylib`.
2. export `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH` or
  `DYLD_FALLBACK_LIBRARY_PATH` to `/usr/local/lib`.
3. remove signature from dotnet binary:
  `sudo codesign --remove-signature $(command -v dotnet)`

This patch adds a fallback lookup for libgdiplus.dylib, to avoid
workaround on macOS (as it is done for Linux: `libgdiplus.so` falls
back to `libgdiplus.so.0`).

Also removed `LIBSEARCHPATH` which is unused since 8d5e610.
@ghost
Copy link

ghost commented Aug 28, 2020

Tagging subscribers to this area: @safern, @tannergooding
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@jkotas jkotas merged commit 88d5e9d into dotnet:master Sep 1, 2020
@am11 am11 deleted the feature/libgdiplus-dllimport-search-path branch September 1, 2020 03:25
@am11
Copy link
Member Author

am11 commented Sep 1, 2020

Would it be possible to consider it for 5.0? It helps the common macOS use-case, where code is using System.Drawing (and user had done: brew install mono-libgdiplus).

@safern
Copy link
Member

safern commented Sep 1, 2020

cc: @ericstj for that question

@ericstj
Copy link
Member

ericstj commented Sep 1, 2020

Has anything made this harder more recently, or has this bug been present since 2.x?

@safern
Copy link
Member

safern commented Sep 1, 2020

It has been present since 2.x if I remember correctly.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants