Skip to content

Commit

Permalink
use plugin for musl
Browse files Browse the repository at this point in the history
commit_hash:e97d8794f04c155eaca0fa4161658142d04e4788
  • Loading branch information
pg committed Feb 12, 2025
1 parent 11b5b34 commit 21b0ebc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
15 changes: 0 additions & 15 deletions build/scripts/link_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ def get_leaks_suppressions(cmd):
return supp, newcmd


MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil'


CUDA_LIBRARIES = {
'-lcublas_static': '-lcublas',
'-lcublasLt_static': '-lcublasLt',
Expand Down Expand Up @@ -258,14 +255,6 @@ def fix_sanitize_flag(cmd, opts):
return flags


def fix_cmd_for_musl(cmd):
flags = []
for flag in cmd:
if flag not in MUSL_LIBS:
flags.append(flag)
return flags


def fix_cmd_for_dynamic_cuda(cmd):
flags = []
for flag in cmd:
Expand Down Expand Up @@ -325,7 +314,6 @@ def fix_blas_resolving(cmd):
def parse_args(args):
parser = optparse.OptionParser()
parser.disable_interspersed_args()
parser.add_option('--musl', action='store_true')
parser.add_option('--custom-step')
parser.add_option('--python')
parser.add_option('--source-root')
Expand Down Expand Up @@ -364,9 +352,6 @@ def parse_args(args):
cmd = fix_blas_resolving(args)
cmd = fix_py2(cmd)
cmd = remove_excessive_flags(cmd)
if opts.musl:
cmd = fix_cmd_for_musl(cmd)

cmd = fix_sanitize_flag(cmd, opts)

if opts.dynamic_cuda:
Expand Down
1 change: 0 additions & 1 deletion build/ymake.core.conf
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ module _BASE_UNIT: _BARE_UNIT {
when ($MUSL == "yes") {
CFLAGS += -D_musl_
LINK_DYN_LIB_FLAGS += --musl
LINK_SCRIPT_EXE_FLAGS += --musl
PEERDIR+=contrib/libs/musl/include
}

Expand Down
18 changes: 18 additions & 0 deletions contrib/libs/musl/musl.pyplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

import os
import sys
import json


MUSL_LIBS = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil'


def fix_cmd_for_musl(cmd):
for flag in cmd:
if flag not in MUSL_LIBS:
yield flag


if __name__ == '__main__':
sys.stdout.write(json.dumps(list(fix_cmd_for_musl(sys.argv[1:]))))
2 changes: 2 additions & 0 deletions contrib/libs/musl/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ CFLAGS(
-D__libc_free=free
)

LD_PLUGIN(musl)

EXTRALIBS(
-nostdlib
-fno-pie
Expand Down

0 comments on commit 21b0ebc

Please sign in to comment.