From owner-freebsd-hackers@freebsd.org Fri Nov 22 19:08:29 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A4EA1BEB68 for ; Fri, 22 Nov 2019 19:08:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47KQv12gLxz470J; Fri, 22 Nov 2019 19:08:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from [192.168.0.5] (unknown [181.52.72.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: pfg) by smtp.freebsd.org (Postfix) with ESMTPSA id CD2AC147AF; Fri, 22 Nov 2019 19:08:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) To: Gleb Popov , freebsd-hackers From: Pedro Giffuni Subject: Re: Linking Linux library to FreeBSD program. Organization: FreeBSD Message-ID: <62bb6535-f970-a2fd-634c-63fbc7890325@FreeBSD.org> Date: Fri, 22 Nov 2019 14:08:27 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Nov 2019 19:08:29 -0000 > Hello hackers@ > > In my quest for CUDA on FreeBSD I managed to compile a simple CUDA program > using native clang. However, it required linking to libcudart.so from Linux > CUDA distribution. > > As you can guess, running this binary results in a segfault - a.out being a > FreeBSD binary tries to load libcudart.so Linux library, which in turn > pulls Linux libc.so. > > What course of action could be taken in this situation? My plan is to > generate a native wrapper library for libcudart.so in which every exported > function would call Linux binary linked to real libcudart.so and route > function arguments via RPC or some other mechanism. This looks awful for > sure, but I don't see any other solutions. Hi; FWIW, I don't know how much alive it still is, but Debian kFreeBSD[1] had a native port of glibc to FreeBSD. Cheers, Pedro. [1] https://www.debian.org/ports/kfreebsd-gnu/