fix link flags of suffix versioned libs#3908
fix link flags of suffix versioned libs#3908xiaopeng-tranxmart wants to merge 4 commits intobazelbuild:mainfrom
Conversation
| "-ldylib=%s" % get_lib_name(artifact), | ||
| ] | ||
| lib_file_name = artifact.basename | ||
| if lib_file_name.startswith("lib") and lib_file_name.endswith(".so"): |
There was a problem hiding this comment.
Could you check how this interacts with get_lib_name_for_windows? (I'm a bit worried that this check is overly specific to linux and may regress windows.)
There was a problem hiding this comment.
Good catch. It appears that the library search behavior on Windows and Darwin differs from Linux. Since I’m not familiar with those platforms, this change is currently limited to Linux only.
Head branch was pushed to by a user without write access
|
Fixed a buildifier lint error. |
|
Friendly ping, this pr is ready |
|
ping @krasimirgg |
|
It seems like there was a conflict introduced |
1cd580b to
0ac402c
Compare
|
Conflict resolved by adding parameter |
Problem
When a versioned shared library (e.g.
libcheryl.so.3.8) is used, the current behavior generates linker flags such as:rustc -dylib=cherylgcc -lcherylThese flags assume the presence of an unversioned shared library (
libcheryl.so). As a result, linking fails when only versioned libraries (e.g.,libcheryl.so.3.8) are available:The correct linker options in this case should explicitly reference the versioned
.so:rustc -Clink-arg=-l:libcheryl.so.3.8gcc -l:libcheryl.so.3.8Solution
IMO, the current implementation assumes that users always provide unversioned shared libraries (
libxxx.so). This assumption is too restrictive:.sosymlink (e.g., onlylibxxx.so.X.Yexists)libxxx.soconvention (e.g.,xxx.so.1)This PR updates the linking behavior as follows:
lib<name>.so, generate-ldylib=<name>-Clink-arg=-l:<filename>