Page MenuHomeFreeBSD

arichardson (Alexander Richardson)
User

Projects

User Details

User Since
Jan 17 2017, 2:21 PM (156 w, 3 d)

Recent Activity

Yesterday

arichardson added a comment to D23229: Build hard-float lib32 for mips64hf/mips64elhf.
In D23229#509463, @jhb wrote:

Yes, I was testing this locally, though without the :=, just a plain =. I was testing it as part of a make tinderbox run though that is only on amd64 and hasn't gotten to mips, so hadn't seen breakage that would require :=.

Fri, Jan 17, 8:56 PM
arichardson added a comment to D23204: Use clang and lld as the default toolchain for MIPS..
In D23204#509367, @jhb wrote:

mips64hf is currently broken because libc_nossp is built as soft-float (I think this is the lib32 version only since the error happens when building rtld-elf32):

ld: error: /home/alr48/obj/build/freebsd-universe-build/exports/users/alr48/sources/freebsd-universe/mips.mips64hf/libexec/rtld-elf32/rtld_libc.a(lstat.nossppico): floating point ABI '-msoft-float' is incompatible with target floa
ting point ABI '-mdouble-float'

I almost fixed this when fixing the mips64el case. Probably what we should do is set the 32-bit MACHINE_ARCH to MACHINE_ARCH:s/64// or some such to preserve el and hf suffixes.
However, note that part of the real problem here is that rtld-elf32 is somewhat broken in that it lets CFLAGS from the non-compat MACHINE_ARCH "leak" through. This doesn't
happen for the lib32 stage which is why the lib32 stage was building as soft-float since the MACHINE was "mips" but does happen for rtld-elf32. That's probably a bug in the bsd.compat.mk thing that @brooks might want to look at.

Fri, Jan 17, 7:21 PM
arichardson accepted D23174: Add qsort_s(3).
Fri, Jan 17, 2:50 PM
arichardson added inline comments to D23174: Add qsort_s(3).
Fri, Jan 17, 12:31 PM
arichardson added a comment to D23204: Use clang and lld as the default toolchain for MIPS..

I also tried building n32 but that fails when linking the syscall objects. My guess is that SYS.h is missing the PIC n32 case and always generates position dependent assembly.

ld: error: can't create dynamic relocation R_MIPS_HI16 against symbol: __cerror in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in cerror.pico
>>> referenced by shm_rename.S:4
>>>               shm_rename.pico:(__sys_shm_rename)
Fri, Jan 17, 11:38 AM
arichardson created D23229: Build hard-float lib32 for mips64hf/mips64elhf.
Fri, Jan 17, 11:11 AM
arichardson added a comment to D23204: Use clang and lld as the default toolchain for MIPS..

I also tried building n32 but that fails when linking the syscall objects. My guess is that SYS.h is missing the PIC n32 case and always generates position dependent assembly.

Fri, Jan 17, 10:47 AM
arichardson planned changes to D23204: Use clang and lld as the default toolchain for MIPS..

mips64hf is currently broken because libc_nossp is built as soft-float (I think this is the lib32 version only since the error happens when building rtld-elf32):

Fri, Jan 17, 10:46 AM
arichardson added inline comments to D23174: Add qsort_s(3).
Fri, Jan 17, 10:40 AM
arichardson requested changes to D23174: Add qsort_s(3).
Fri, Jan 17, 10:39 AM

Thu, Jan 16

arichardson accepted D23174: Add qsort_s(3).

Looks fine to me but someone else should give the final approval.

Thu, Jan 16, 11:09 PM
arichardson committed rS356791: Allow building bin/cat on non-FreeBSD systems.
Allow building bin/cat on non-FreeBSD systems
Thu, Jan 16, 2:15 PM
arichardson closed D13939: Allow building bin/cat on non-FreeBSD systems.
Thu, Jan 16, 2:15 PM
arichardson closed D23202: Allow bootstrapping mkimg on macOS/Linux.
Thu, Jan 16, 2:15 PM
arichardson committed rS356790: Allow bootstrapping mkimg on macOS/Linux.
Allow bootstrapping mkimg on macOS/Linux
Thu, Jan 16, 2:15 PM
arichardson committed rS356789: Merge commit 894f742acb from llvm git (by me):.
Merge commit 894f742acb from llvm git (by me):
Thu, Jan 16, 2:15 PM
arichardson closed D23203: Merge commit 894f742acb from llvm git (by me):.
Thu, Jan 16, 2:15 PM
arichardson added a comment to D23204: Use clang and lld as the default toolchain for MIPS..

I guess I could try to build and boot a n32 world, but I'm not sure which kernel I should be using to test it.

Thu, Jan 16, 2:07 PM
arichardson planned changes to D14245: crossbuild: disable MK_* options that won't work on non-FreeBSD systems.

No longer accurate, I have changes to allow bootstrapping localedef and CDDL code.

Thu, Jan 16, 12:48 PM
arichardson created D23204: Use clang and lld as the default toolchain for MIPS..
Thu, Jan 16, 11:48 AM
arichardson added inline comments to D23201: Allow bootstrapping makefs on older FreeBSD hosts and Linux/mac.
Thu, Jan 16, 11:02 AM
arichardson added a comment to D23203: Merge commit 894f742acb from llvm git (by me):.

I am not sure what the correct process is to merge upstream LLVM changes. Is it fine to just commit this diff or are any other steps required?

Thu, Jan 16, 10:40 AM
arichardson created D23203: Merge commit 894f742acb from llvm git (by me):.
Thu, Jan 16, 10:39 AM
arichardson created D23202: Allow bootstrapping mkimg on macOS/Linux.
Thu, Jan 16, 10:20 AM
arichardson created D23201: Allow bootstrapping makefs on older FreeBSD hosts and Linux/mac.
Thu, Jan 16, 10:19 AM
arichardson created D23200: makefs (msdosfs): Use fprintf instead of debug print for errors.
Thu, Jan 16, 10:10 AM

Wed, Jan 15

arichardson added inline comments to D23174: Add qsort_s(3).
Wed, Jan 15, 10:04 AM

Fri, Jan 10

arichardson added a comment to D17002: Fix compilation with upstream clang builtin headers.

Ping? Can we merge this or do I have to convince upstream LLVM to add checks for the FreeBSD _FOO_DECLARED macros to their stddef.h/stdarg.h? I'm not sure how willing they would be to make that change though.

Fri, Jan 10, 2:54 PM
arichardson planned changes to D13939: Allow building bin/cat on non-FreeBSD systems.
Fri, Jan 10, 2:50 PM
arichardson added a comment to D13939: Allow building bin/cat on non-FreeBSD systems.

I agree that a small separate tool would be nicer. I don't really have time to write one right now though. I'll wait before committing this until it's the last blocker for cross-building. Maybe by then I'll find some time to add a write_locked (or whatever name we want to choose) bootstrap tool.

Fri, Jan 10, 2:50 PM

Sun, Jan 5

arichardson added a comment to D13939: Allow building bin/cat on non-FreeBSD systems.

Ping?

Sun, Jan 5, 4:51 PM

Thu, Jan 2

arichardson accepted D21697: Fix MIPS CSU compilation w/ LLVM.

Looks good. Compiles for me with latest LLVM.

Thu, Jan 2, 2:49 PM

Dec 10 2019

arichardson added a comment to D22630: Include <sys/cdefs.h> in execinfo.h.
In D22630#497926, @cem wrote:

This is for cross-building?
FreeBSD's stddef.h includes sys/cdefs.h. If you aren't finding FreeBSD's stddef.h in a cross build, why would you expect to find FreeBSD's sys/cdefs.h?
I guess glibc's sys/cdefs.h includes __BEGIN_DECLS, etc, but I don't know how portable that assumption is (no idea what MacOS has, and I don't know if windows environments like mingw64 have a sys/cdefs.h).
I'd prefer a more holistic approach — use the src tree FreeBSD's headers when we're cross-compiling, rather than the host's.

Dec 10 2019, 9:19 PM
arichardson committed rS355582: Use ${.ALLSRC:Ninstalldirs-*} instead of assuming order of .ALLSRC.
Use ${.ALLSRC:Ninstalldirs-*} instead of assuming order of .ALLSRC
Dec 10 2019, 12:13 PM

Dec 2 2019

arichardson created D22630: Include <sys/cdefs.h> in execinfo.h.
Dec 2 2019, 9:39 AM

Nov 21 2019

arichardson added a comment to D22464: Makefile.inc1: push /usr/libexec into the BPATH/TMPPATH .

LGTM. Only concern might be that adding /usr/libexec to PATH adds too much stuff.
Hopefully I can get the strict tmppath usable by default soon so it shouldn't matter anymore then.

Yeah, so what I really wanted here with flua was some way to indicate that flua can/should be symlinked in from the host (preferably to the same location that I've added to BPATH) on the versions it's *not* being bootstrapped (__FreeBSD_version after I added it) to simplify this, since I don't really want to add /usr/libexec. Any advice on making that happen (or just getting flua into one of the standard BPATH/XPATH paths while leaving it installing to /usr/libexec) is quite welcome. =)

It should be possible to modify tools/build/Makefile and change the host-symlinks target to add a flua symlink if it exists on the host.
Something like (untested):

.if exists(/usr/libexec/flua)
    mkdir -p ${DESTDIR}/usr/libexec
    ln -sf /usr/libexec/flua ${DESTDIR}/usr/libexec/flua
.endif

Yeah, I like that, thanks! I think the mkdir -p can safely be omitted -- we create it in the installdirs target now in case it's bootstrapped, which should always be run prior to host-symlinks if I understand correctly. If we later determine flua needs to be bootstrapped, that just gets built+installed over the symlink, right?

Nov 21 2019, 7:54 AM

Nov 20 2019

arichardson added a comment to D22464: Makefile.inc1: push /usr/libexec into the BPATH/TMPPATH .

LGTM. Only concern might be that adding /usr/libexec to PATH adds too much stuff.
Hopefully I can get the strict tmppath usable by default soon so it shouldn't matter anymore then.

Yeah, so what I really wanted here with flua was some way to indicate that flua can/should be symlinked in from the host (preferably to the same location that I've added to BPATH) on the versions it's *not* being bootstrapped (__FreeBSD_version after I added it) to simplify this, since I don't really want to add /usr/libexec. Any advice on making that happen (or just getting flua into one of the standard BPATH/XPATH paths while leaving it installing to /usr/libexec) is quite welcome. =)

Nov 20 2019, 10:50 PM
arichardson accepted D22464: Makefile.inc1: push /usr/libexec into the BPATH/TMPPATH .

LGTM. Only concern might be that adding /usr/libexec to PATH adds too much stuff.

Nov 20 2019, 9:32 PM
arichardson committed rS354901: Allow boostrapping xinstall on Linux.
Allow boostrapping xinstall on Linux
Nov 20 2019, 5:25 PM
arichardson closed D22446: Allow boostrapping xinstall on Linux.
Nov 20 2019, 5:25 PM

Nov 19 2019

arichardson updated subscribers of D22446: Allow boostrapping xinstall on Linux.
Nov 19 2019, 11:19 PM
arichardson created D22446: Allow boostrapping xinstall on Linux.
Nov 19 2019, 5:58 PM

Nov 17 2019

arichardson committed rS354796: Fix error found by new clang operator precendence warning.
Fix error found by new clang operator precendence warning
Nov 17 2019, 7:04 PM
arichardson closed D22433: Fix error found by new clang operator precendence warning.
Nov 17 2019, 7:04 PM
arichardson created D22433: Fix error found by new clang operator precendence warning.
Nov 17 2019, 5:27 PM

Nov 15 2019

arichardson added a comment to D17002: Fix compilation with upstream clang builtin headers.
In D17002#489675, @jhb wrote:

Does this work with GCC? Seems no:

> mips-unknown-freebsd12.1-gcc -print-resource-dir
mips-unknown-freebsd12.1-gcc: error: unrecognized command line option '-print-resource-dir'; did you mean '-print-search-dirs'?
mips-unknown-freebsd12.1-gcc: fatal error: no input files
compilation terminated.
Nov 15 2019, 9:53 PM
arichardson added a comment to D17002: Fix compilation with upstream clang builtin headers.

This change is required to build with an unmodified upstream LLVM since the default upstream clang builtin headers are incompatible with the ones in /usr/bin/include (see my earlier comments in this review).

Nov 15 2019, 8:29 PM
arichardson committed rS354740: Fix build race in bsd.files.mk.
Fix build race in bsd.files.mk
Nov 15 2019, 6:34 PM
arichardson closed D22382: Fix build race in bsd.files.mk.
Nov 15 2019, 6:34 PM
arichardson closed D22386: makefs: Also set UFS di_birthtime when building on Linux.
Nov 15 2019, 6:34 PM
arichardson committed rS354739: makefs: Also set UFS di_birthtime when building on Linux.
makefs: Also set UFS di_birthtime when building on Linux
Nov 15 2019, 6:34 PM
arichardson closed D22387: Fix contents= being ignored in msdosfs makefs mtree.
Nov 15 2019, 6:34 PM
arichardson committed rS354738: Fix contents= being ignored in msdosfs makefs mtree.
Fix contents= being ignored in msdosfs makefs mtree
Nov 15 2019, 6:34 PM
arichardson added a comment to D17002: Fix compilation with upstream clang builtin headers.

ping

Nov 15 2019, 5:43 PM
arichardson created D22387: Fix contents= being ignored in msdosfs makefs mtree.
Nov 15 2019, 5:38 PM
arichardson created D22386: makefs: Also set UFS di_birthtime when building on Linux.
Nov 15 2019, 5:36 PM
arichardson committed rS354736: Use __ as the separator for the exported vars in bsd.compiler/linker.mk.
Use __ as the separator for the exported vars in bsd.compiler/linker.mk
Nov 15 2019, 4:43 PM
arichardson closed D22381: Use __ as the separator for the exported vars in bsd.compiler/linker.mk.
Nov 15 2019, 4:43 PM
arichardson updated the summary of D13939: Allow building bin/cat on non-FreeBSD systems.
Nov 15 2019, 3:54 PM
arichardson updated the diff for D13939: Allow building bin/cat on non-FreeBSD systems.

Disable all flags except -l/-u when bootstrapping

Nov 15 2019, 3:52 PM
arichardson added reviewers for D22382: Fix build race in bsd.files.mk: sjg, brd, brooks.
Nov 15 2019, 3:46 PM
arichardson created D22382: Fix build race in bsd.files.mk.
Nov 15 2019, 3:45 PM
arichardson created D22381: Use __ as the separator for the exported vars in bsd.compiler/linker.mk.
Nov 15 2019, 3:41 PM

Oct 10 2019

arichardson added a comment to D21971: rpcgen: make compiler arglist allocation dynamic.

I wish the C standard library had some kind of dynamic array so that this is not reimplement in every program...
I wonder if we could use something like the utarray.h macros from uthash?
Could we import the five headers that https://github.com/troydhanson/uthash into contrib and use utarray instead? I know the library is not that efficient since it uses strdup() for all strings that you insert but at least it means not reinventing the wheel.
We already have two copies of uthash.h in the source tree and elftoolchain also includes with utarray.h.

We certainly could use utarray instead, though I'm not super convinced by its readability.
(Importing uthash.h into contrib is on my todo list since I'd like to merge my changes to use it instead of bdb for hashes in init and a couple other places.)

Oct 10 2019, 10:00 PM
arichardson accepted D21971: rpcgen: make compiler arglist allocation dynamic.

I wish the C standard library had some kind of dynamic array so that this is not reimplement in every program...

Oct 10 2019, 9:03 PM

Oct 2 2019

arichardson accepted D21696: Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it around.
Oct 2 2019, 6:57 PM

Sep 26 2019

arichardson added a comment to D21697: Fix MIPS CSU compilation w/ LLVM.

If prefer to just spell out the assembly rather than just the magic cp* macros.
Apparently they place a $gp reload after every call: Additionally, it causes the assembler to emit:

Sep 26 2019, 8:20 AM

Sep 25 2019

arichardson added a comment to D21696: Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it around.

Looks good. Although I'm not sure if we want this to be conditional on clang/lld since modern GCC+bfd should work (and maybe even clang+new bfd).

Sep 25 2019, 6:18 AM

Sep 18 2019

arichardson added a comment to D21699: Hack around incorrect TLS defaults for mips64.

I can't remember why we need this change. There were some cases where we really need inital-exec for executables rather than global-dynamic.
I tend to forget everything about TLS once I no longer need to know it but maybe @jrtc27_jrtc27.com, @brooks or @jhb know.

Sep 18 2019, 1:21 PM
arichardson updated subscribers of D21699: Hack around incorrect TLS defaults for mips64.

I can't remember why we need this change. There were some cases where we really need inital-exec for executables rather than global-dynamic.
I tend to forget everything about TLS once I no longer need to know it but maybe @jrtc27_jrtc27.com, @brooks or @jhb know.

Sep 18 2019, 1:17 PM
arichardson accepted D21699: Hack around incorrect TLS defaults for mips64.

Looks good to me but I'd wait for @jhb to review it too.

Sep 18 2019, 7:59 AM
arichardson accepted D21698: usr.bin/clang: use -mxgot for MIPS.

I guess this happens because some files have more static globals than can be accessed in the immediate. In general lld should be able to use the multi-GOT trick but in that case it won't work.
If we really care about performance we could track down the individual files that need mxgot and only add it there but asking it globally should be fine.

Sep 18 2019, 7:55 AM

Sep 17 2019

arichardson added a reviewer for D21681: mips: incredibly naive attempt at 8/16-bit atomics (set/clear/add/sub/cmpset/fcmpset): arichardson.

I believe that splitting the operation into two asm blocks with C code between will break at -O0 since any variable access goes via the stack. This might cause the sc to fail.

Sep 17 2019, 11:33 PM

Sep 11 2019

arichardson accepted D21605: Avoid the use of the non-portable -D argument to ls..
Sep 11 2019, 1:42 PM

Aug 29 2019

arichardson added a comment to D21435: mips: fix _mcount.

LGTM but I also haven't tested it. I don't know how useful the profile stuff is. If it's not implemented for MIPS64 anyway we could just not build it?

Aug 29 2019, 7:53 PM

Aug 15 2019

arichardson accepted D21274: rtld-elf: fix build with xtoolchain-llvm90.
Aug 15 2019, 4:04 PM

Jul 30 2019

D21088: Avoid conflicts with libc symbols in libthr jump table. is now accepted and ready to land.
Jul 30 2019, 1:07 PM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

Just found one more issue but otherwise LGTM. Maybe better to consistently use the _Tthr prefix.

Jul 30 2019, 11:43 AM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

I can confirm that it works when I apply the following change on top of your patch:

diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index d9bde8a37c9d..78146c2d6dcd 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -257,7 +257,7 @@ static pthread_func_t jmp_table[][2] = {
        [PJT_RWLOCK_TRYWRLOCK] = {DUAL_ENTRY(_Tthr_rwlock_trywrlock)},
        [PJT_RWLOCK_UNLOCK] = {DUAL_ENTRY(_Tthr_rwlock_unlock)},
        [PJT_RWLOCK_WRLOCK] = {DUAL_ENTRY(_Tthr_rwlock_wrlock)},
-       [PJT_SELF] = {DUAL_ENTRY(_thr_self)},
+       [PJT_SELF] = {DUAL_ENTRY(_Tthr_self)},
        [PJT_SETCANCELSTATE] = {DUAL_ENTRY(_thr_setcancelstate)},
        [PJT_SETCANCELTYPE] = {DUAL_ENTRY(_thr_setcanceltype)},
        [PJT_SETSPECIFIC] = {DUAL_ENTRY(_thr_setspecific)},
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 90385d1ab31c..47b82009765d 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -1069,7 +1069,7 @@ int _thr_setspecific(pthread_key_t, const void *);
 void *_thr_getspecific(pthread_key_t);
 int _thr_setcancelstate(int, int *);
 int _thr_setcanceltype(int, int *);
-pthread_t _thr_self(void);
+pthread_t _Tthr_self(void);
 int _thr_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);
 int _thr_rwlock_destroy(pthread_rwlock_t *);
 int _Tthr_rwlock_rdlock(pthread_rwlock_t *);
diff --git a/lib/libthr/thread/thr_self.c b/lib/libthr/thread/thr_self.c
index 168d91721e0b..68bf5bc39312 100644
--- a/lib/libthr/thread/thr_self.c
+++ b/lib/libthr/thread/thr_self.c
@@ -38,11 +38,11 @@ __FBSDID("$FreeBSD$");
Jul 30 2019, 8:51 AM
arichardson added inline comments to D21088: Avoid conflicts with libc symbols in libthr jump table..
Jul 30 2019, 8:40 AM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

Some more information:

(lldb) register read
General Purpose Registers:
       rax = 0x00000000000001b0
       rbx = 0x0000000000000001
       rcx = 0x00007fffffffeb10
       rdx = 0x00000000002050fd
       rdi = 0x000000000031d2e8  __sF + 312
       rsi = 0x000000000031bec0  __xlocale_global_locale
       rbp = 0x00007fffffffe890
       rsp = 0x00007fffffffe878
        r8 = 0x00007fffffffeb10
        r9 = 0x00007fffffffeb10
       r10 = 0x00007fffffffeb10
       r11 = 0x0000000000000201
       r12 = 0x00000000002002e0
       r13 = 0x00000000002002e0
       r14 = 0x00007fffffffebd8
       r15 = 0x00007fffffffebe8
       rip = 0x00000000002fd4b8  test-c-first`__sys_thr_self + 8
    rflags = 0x0000000000000202
        cs = 0x0000000000000043
Jul 30 2019, 8:35 AM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

With -O0 at the time of the crash:

(lldb) p *__stdoutp
(FILE) $1 = {
  _p = 0x00000000000186e8 ""
  _r = 0
  _w = 0
  _flags = 2185
  _file = 1
  _bf = (_base = "pthread_create = 0x301e10\n\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5)
  _lbfsize = -4096
  _cookie = 0x000000000031d2e8
  _close = 0x00000000002fe580 (test-c-first`__sclose at stdio.c:80)
  _read = 0x00000000002fe4c0 (test-c-first`__sread at stdio.c:56)
  _seek = 0x00000000002fe540 (test-c-first`__sseek at stdio.c:72)
  _write = 0x00000000002fe500 (test-c-first`__swrite at stdio.c:64)
  _ub = (_base = 0x0000000000000000, _size = 0)
  _up = 0x0000000000000000
  _ur = 0
  _ubuf = ""
  _nbuf = ""
  _lb = (_base = 0x0000000000000000, _size = 0)
  _blksize = 4096
  _offset = 0
  _fl_mutex = 0x0000000000000000
  _fl_owner = 0x0000000000000000
  _fl_count = 1
  _orientation = 0
  _mbstate = (__mbstate8 = "", _mbstateL = 0)
  _flags2 = 0
}
(lldb) p __stdoutp->_bf._base
(unsigned char *) $4 = 0x000000080033b000 "pthread_create = 0x301e10\n\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa5\xa.
(lldb) p __stdoutp->_bf._size
(int) $5 = 4096
Jul 30 2019, 8:31 AM

Jul 29 2019

arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

Just to be clear this only happens if I actually start a thread and call pthread_join (using the program I posted here). The simple case from the PR works fine.

Jul 29 2019, 9:13 PM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..
In D21088#458174, @kib wrote:

I am now getting a very strange error:

root@qemu-native-alr48:~ # clang -static -o test-thr-first -nodefaultlibs -lthr -lc test.c -fuse-ld=lld && ./test-thr-first
pthread_create = 0x2693d0
result = 0x1234
root@qemu-native-alr48:~ # clang -static -o test-c-first -nodefaultlibs -lc -lthr test.c -fuse-ld=lld && ./test-c-first
pthread_create = 0x2a58a0
Segmentation fault (core dumped)
root@qemu-native-alr48:~ # clang -static -o test-c-first -nodefaultlibs -lc -lthr test.c -fuse-ld=lld && lldb -- ./test-c-first
(lldb) target create "./test-c-first"
Current executable set to './test-c-first' (x86_64).
(lldb) r
Process 746 launching
Process 746 launched: '/root/test-c-first' (x86_64)
pthread_create = 0x2a58a0
Process 746 stopped
* thread #1, name = 'test-c-first', stop reason = signal SIGSEGV: invalid address (fault address: 0x186e8)
    frame #0: 0x00000000002a4b8d test-c-first`memcpy at memmove.S:306
(lldb) bt
* thread #1, name = 'test-c-first', stop reason = signal SIGSEGV: invalid address (fault address: 0x186e8)
  * frame #0: 0x00000000002a4b8d test-c-first`memcpy at memmove.S:306
    frame #1: 0x00000000002a2b53 test-c-first`__sfvwrite(fp=<unavailable>, uio=0x00007fffffffe888) at fvwrite.c:188:5
    frame #2: 0x0000000000285442 test-c-first`__vfprintf [inlined] __sprint(fp=<unavailable>, uio=<unavailable>, locale=<unavailable>) at vfprintf.c:166:8
    frame #3: 0x0000000000285436 test-c-first`__vfprintf [inlined] io_flush(iop=<unavailable>, locale=<unavailable>) at printfcommon.h:157
    frame #4: 0x000000000028541f test-c-first`__vfprintf(fp=0x00000000002b7ff8, locale=0x00000000002b6bf8, fmt0=<unavailable>, ap=0x00007fffffffeb10) at vfprintf.c:1033
    frame #5: 0x0000000000281ebd test-c-first`vfprintf_l(fp=0x00000000002b7ff8, locale=0x00000000002b6bf8, fmt0="result = %p\n", ap=0x00007fffffffeb10) at vfprintf.c:285:9
    frame #6: 0x00000000002a57ba test-c-first`printf(fmt=<unavailable>) at printf.c:57:8
    frame #7: 0x00000000002a5707 test-c-first`main + 119
    frame #8: 0x000000000022510f test-c-first`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7

Indeed strange. I cannot reproduce it locally. For me it is just

x% ./test-c-first                     /usr/home/pooma/build/bsd/DEV/stuff/tests
pthread_create = 0x2a58b0
x%

Can you build libc with debugging info and lower optimization level (DEBUG_FLAGS=-g should be enough), and then print out the stdout FILE state ? I suspect there is some problem there.

Jul 29 2019, 9:11 PM

Jul 28 2019

arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

I am now getting a very strange error:

root@qemu-native-alr48:~ # clang -static -o test-thr-first -nodefaultlibs -lthr -lc test.c -fuse-ld=lld && ./test-thr-first
pthread_create = 0x2693d0
result = 0x1234
root@qemu-native-alr48:~ # clang -static -o test-c-first -nodefaultlibs -lc -lthr test.c -fuse-ld=lld && ./test-c-first
pthread_create = 0x2a58a0
Segmentation fault (core dumped)
root@qemu-native-alr48:~ # clang -static -o test-c-first -nodefaultlibs -lc -lthr test.c -fuse-ld=lld && lldb -- ./test-c-first
(lldb) target create "./test-c-first"
Current executable set to './test-c-first' (x86_64).
(lldb) r
Process 746 launching
Process 746 launched: '/root/test-c-first' (x86_64)
pthread_create = 0x2a58a0
Process 746 stopped
* thread #1, name = 'test-c-first', stop reason = signal SIGSEGV: invalid address (fault address: 0x186e8)
    frame #0: 0x00000000002a4b8d test-c-first`memcpy at memmove.S:306
(lldb) bt
* thread #1, name = 'test-c-first', stop reason = signal SIGSEGV: invalid address (fault address: 0x186e8)
  * frame #0: 0x00000000002a4b8d test-c-first`memcpy at memmove.S:306
    frame #1: 0x00000000002a2b53 test-c-first`__sfvwrite(fp=<unavailable>, uio=0x00007fffffffe888) at fvwrite.c:188:5
    frame #2: 0x0000000000285442 test-c-first`__vfprintf [inlined] __sprint(fp=<unavailable>, uio=<unavailable>, locale=<unavailable>) at vfprintf.c:166:8
    frame #3: 0x0000000000285436 test-c-first`__vfprintf [inlined] io_flush(iop=<unavailable>, locale=<unavailable>) at printfcommon.h:157
    frame #4: 0x000000000028541f test-c-first`__vfprintf(fp=0x00000000002b7ff8, locale=0x00000000002b6bf8, fmt0=<unavailable>, ap=0x00007fffffffeb10) at vfprintf.c:1033
    frame #5: 0x0000000000281ebd test-c-first`vfprintf_l(fp=0x00000000002b7ff8, locale=0x00000000002b6bf8, fmt0="result = %p\n", ap=0x00007fffffffeb10) at vfprintf.c:285:9
    frame #6: 0x00000000002a57ba test-c-first`printf(fmt=<unavailable>) at printf.c:57:8
    frame #7: 0x00000000002a5707 test-c-first`main + 119
    frame #8: 0x000000000022510f test-c-first`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7
Jul 28 2019, 9:37 PM

Jul 27 2019

D21088: Avoid conflicts with libc symbols in libthr jump table. is now accepted and ready to land.

Approach is definitely viable. However, if we need to update all functions a macro is probably a good idea.

Jul 27 2019, 9:41 PM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

Seems like it will still break for all other functions that aren't updated?

Jul 27 2019, 9:17 PM
arichardson added a comment to D21088: Avoid conflicts with libc symbols in libthr jump table..

However, I just noticed that the following test case still results in an infinite loop/recursion even with this patch. I prints the address of pthread_create, but then freezes. Guess we need to do the same trick for even more functions.

#include <stdio.h>
#include <pthread.h>
Jul 27 2019, 6:37 PM
D21088: Avoid conflicts with libc symbols in libthr jump table. is now accepted and ready to land.

Thanks! I can confirm that it works for the testcase from the PR if I apply the suggested fix.

Jul 27 2019, 6:13 PM

Jul 19 2019

arichardson added a comment to D21002: ata_xpt: Use the correct union member when accessing valid.

I'm not sure why I made that change. I just remember that we had some compiler bugs in that function that went away when I added a printf. I think this was just one of the suspicious things that I saw so I made the change hoping that it would fix the miscompilation.

Jul 19 2019, 10:42 PM

Jul 2 2019

arichardson committed rS349615: Fix build race when building rtld.
Fix build race when building rtld
Jul 2 2019, 10:11 PM

Jul 1 2019

arichardson committed rS349577: Allow bootstrapping elftoolchain on MacOS and Linux.
Allow bootstrapping elftoolchain on MacOS and Linux
Jul 1 2019, 11:53 AM
arichardson closed D16771: Allow bootstrapping elftoolchain on MacOS and Linux.
Jul 1 2019, 11:53 AM
arichardson closed D16849: Fix generation of krb5-config with LC_CTYPE=*.UTF-8.
Jul 1 2019, 11:48 AM
arichardson committed rS349576: Fix generation of krb5-config with LC_CTYPE=*.UTF-8.
Fix generation of krb5-config with LC_CTYPE=*.UTF-8
Jul 1 2019, 11:48 AM
arichardson added a comment to D17002: Fix compilation with upstream clang builtin headers.

@bdrewery is this okay to commit now?

Jul 1 2019, 11:47 AM
arichardson added a comment to D17799: Stop using ld -r + objcopy to create i386 crt1.o.

lld has been fixed.

Jul 1 2019, 11:45 AM

Jun 30 2019

arichardson committed rS349561: Fix CROSS_TOOLCHAIN=amd64-gcc build after r349554.
Fix CROSS_TOOLCHAIN=amd64-gcc build after r349554
Jun 30 2019, 5:03 PM
arichardson committed rS349555: Fix my name in license header.
Fix my name in license header
Jun 30 2019, 2:04 PM
arichardson committed rS349554: Reduce size of rtld by 22% by pulling in less code from libc.
Reduce size of rtld by 22% by pulling in less code from libc
Jun 30 2019, 11:50 AM