Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Feb 2019 20:44:58 +0100
From:      =?UTF-8?B?VMSzbA==?= Coosemans <tijl@FreeBSD.org>
To:        "Jin Guojun[VFF]" <jguojun@gmail.com>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: what causes Clang to use libgcc_s.so in FreeBSD 12.0-R linker
Message-ID:  <20190224204458.5652577c@kalimero.tijl.coosemans.org>
In-Reply-To: <14887cbb-a6ef-c6ac-f7b2-2d91e4c72351@gmail.com>
References:  <14887cbb-a6ef-c6ac-f7b2-2d91e4c72351@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 13 Feb 2019 17:31:46 -0800 "Jin Guojun[VFF]" <jguojun@gmail.com>
wrote:
> Following CC command used for build a shared library that worked on all=20
> FreeBSD releases before 12-R.
>=20
> The -v CC option shows that linker indeed involves libgcc and gcc_s=20
> somehow, but no -static option was shown. Not clear what the error=20
> message implies. Also, none of these source code has GNU stuff in it and=
=20
> what linker tried to do with gcc libraries?
>=20
> Is something changed for building shared libraries under 12-R?
>=20
> Thanks,
>=20
> -Jin
>=20
>=20
> FBSD12:=C2=A0 cc -Wl,-r -o libccs.so `lorder avail_type.so arg_vc.so=20
> c_array.so calibrate.so colortog
> .so c_map.so colort90.so dbvfft3d.so eta.so errors.so filter_f.so=20
> fits_io.so fourier.so gaussian
> .so glb_vars.so histgram.so icc_r.so io_ready.so libpbm.so libpbm2.so=20
> libpbm4.so libpgm1.so libp
> pm1.so libppm3.so libpbm1.so ln2argv.so message.so pict_r.so pgm_r.so=20
> q_sort.so rotate90.so t_co
> nsum.so tv_random.so time-out.so dbg_memsz.so to_sep.so to_8.so=20
> quantto8.so sub_mean.so zalloc.s
> o vfft3d.so vfft_2p.so c_map1.so c_to_c.so buffernw.so checksum.so=20
> dicm_h.so dir_unix.so eget_ws
> z.so gif_r.so ip-hdr.so private.so piperead.so parsargu.so rast_r.so=20
> sock_cnct.so sock_init.so s
> ock_subr.so swap_all.so table_if.so tv_empty.so tvmath.so u_db.so=20
> zreopen.so pip_read.so | tsort
> `
>=20
> /usr/bin/ld: error: attempted static link of dynamic object=20
> /usr/lib/libgcc_s.so
> /usr/bin/ld: error: attempted static link of dynamic object=20
> /usr/lib/libgcc_s.so
> cc: error: linker command failed with exit code 1 (use -v to see invocati=
on)
> *** Error code 1 (ignored)
>=20
> FBSD12: cc -v -Wl,-r -o libccs.so `lorder avail_type.so arg_vc.so=20
> c_array.so calibrate.so colortog.so c
> _map.so colort90.so dbvfft3d.so eta.so errors.so filter_f.so fits_io.so=20
> fourier.so gaussian.so g
> lb_vars.so histgram.so icc_r.so io_ready.so libpbm.so libpbm2.so=20
> libpbm4.so libpgm1.so libppm1.s
> o libppm3.so libpbm1.so ln2argv.so message.so pict_r.so pgm_r.so=20
> q_sort.so rotate90.so t_consum.
> so tv_random.so time-out.so dbg_memsz.so to_sep.so to_8.so quantto8.so=20
> sub_mean.so zalloc.so vff
> t3d.so vfft_2p.so c_map1.so c_to_c.so buffernw.so checksum.so dicm_h.so=20
> dir_unix.so eget_wsz.so
> gif_r.so ip-hdr.so private.so piperead.so parsargu.so rast_r.so=20
> sock_cnct.so sock_init.so sock_s
> ubr.so swap_all.so table_if.so tv_empty.so tvmath.so u_db.so zreopen.so=20
> pip_read.so | tsort`
> FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on=20
> LLVM 6.0.1)
> Target: x86_64-unknown-freebsd12.0
> Thread model: posix
> InstalledDir: /usr/bin
>  =C2=A0"/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1=
=20
> --hash-style=3Dboth --enable-ne
> w-dtags -o libccs.so /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o=
=20
> -L/usr/lib -r pip_read.
> so zreopen.so u_db.so tv_empty.so table_if.so rast_r.so parsargu.so=20
> piperead.so private.so ip-hd
> r.so gif_r.so eget_wsz.so dir_unix.so dicm_h.so checksum.so buffernw.so=20
> c_map1.so vfft_2p.so sub
> _mean.so to_8.so to_sep.so dbg_memsz.so time-out.so tv_random.so=20
> t_consum.so pgm_r.so pict_r.so
> ln2argv.so libppm3.so libppm1.so libpgm1.so libpbm2.so libpbm.so=20
> io_ready.so icc_r.so histgram.s
> o glb_vars.so gaussian.so fits_io.so filter_f.so eta.so dbvfft3d.so=20
> colort90.so c_map.so colorto
> g.so calibrate.so c_array.so arg_vc.so avail_type.so tvmath.so=20
> swap_all.so sock_init.so sock_cnc
> t.so vfft3d.so quantto8.so rotate90.so q_sort.so libpbm1.so libpbm4.so=20
> fourier.so sock_subr.so c
> _to_c.so zalloc.so errors.so message.so -lgcc --as-needed -lgcc_s=20
> --no-as-needed -lc -lgcc --as-
> needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
> /usr/bin/ld: error: attempted static link of dynamic object=20
> /usr/lib/libgcc_s.so
> /usr/bin/ld: error: attempted static link of dynamic object=20
> /usr/lib/libgcc_s.so
> cc: error: linker command failed with exit code 1 (use -v to see invocati=
on)

I'm not really sure what you are trying to do.  You are using -Wl,-r
which suggest you want to combine multiple object files into a single
object file.  Normally the extension .o is used for object files but you
are using .so, which is normally used for libraries.  Then the output is
named libccs.so which suggests you want to create a library.  It's
confusing.

If you want to combine object files you should not use cc, but ld:
ld -r -o libccs.so ...

If you want to create a shared library use this:
cc -shared -o libccs.so ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190224204458.5652577c>