public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/30477] New: riscv32: time64 does not work
@ 2023-05-21 0:59 tsu.yubo at gmail dot com
2023-05-22 9:20 ` [Bug libc/30477] [RISCV]: time64 does not work on riscv32 tsu.yubo at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: tsu.yubo at gmail dot com @ 2023-05-21 0:59 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30477
Bug ID: 30477
Summary: riscv32: time64 does not work
Product: glibc
Version: 2.36
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: tsu.yubo at gmail dot com
CC: drepper.fsp at gmail dot com
Target Milestone: ---
Hi,
Please correct me if any description or my understanding is incorrect.
We found that in riscv32, time64-related system calls do not work on
glibc-2.36.
The example code is below:
```
/* From Gao Han <gaohan@iscas.ac.cn> */
#include <stdio.h>
#include <fcntl.h>
#include <sys/file.h>
#include <errno.h>
// #include <sys/flock.h>
void
setcloexec(int fd, const char *fn)
{
int f;
f = fcntl(fd, F_GETFD);
if (f == -1)
printf("unable to read filedescriptor flags for %.250s",fn);
if (fcntl(fd, F_SETFD, (f|FD_CLOEXEC))==-1)
printf("unable to set close-on-exec flag for %.250s",fn);
}
int main() {
const char* dblockfile = "/var/lib/dpkg/lock";
int dblockfd = open(dblockfile, O_RDWR|O_CREAT|O_TRUNC, 0660);
struct flock fl;
while(1) {
setcloexec(dblockfd, dblockfile);
// lock
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = 0;
if (fcntl(dblockfd, F_SETLK, &fl) == -1) {
printf("lock failed\n");
if (errno == EINVAL) {
printf("Invalid argument");
break;
}
} else {
printf("lock success\n");
}
// unlock
fl.l_type= F_UNLCK;
fl.l_whence= SEEK_SET;
fl.l_start= 0;
fl.l_len= 0;
fl.l_pid = 0;
if (fcntl(dblockfd, F_SETLK, &fl) == -1) {
printf("unlock failed\n");
if (errno == EINVAL) {
printf("Invalid argument");
break;
}
} else {
printf("unlock success\n");
}
usleep(200);
}
}
```
Yes, here we can got `Invalid argument` error. But F_SETLK64 is ok.
This problem arises when we try to build Debian riscv32 rootfs using dpkg. We
can make workaround if pass flags:
```
export DEB_CFLAGS_APPEND="${DEB_CFLAGS_APPEND:+$DEB_CFLAGS_APPEND
}-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
export DEB_CPPFLAGS_APPEND="${DEB_CPPFLAGS_APPEND:+$DEB_CPPFLAGS_APPEND
}-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
```
In other words, we need to enable `lfs` feature. I heard the new 32-bit
platform should support time64 from start from other developers, So it's
contradictory with the fact.
We suspect that we are not ready to enable these flags but I'm not sure if
there is a historical reason for this:
```code
/* RISC-V requires 64-bit off_t */
# define _POSIX_V7_ILP32_OFF32 -1
# define _POSIX_V6_ILP32_OFF32 -1
# define _XBS5_ILP32_OFF32 -1
# define _POSIX_V7_ILP32_OFFBIG 1
# define _POSIX_V6_ILP32_OFFBIG 1
# define _XBS5_ILP32_OFFBIG 1
```
https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/riscv/bits/environments.h#L62
Please help to confirm this and I will help to fix the issue.
TIA.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/30477] [RISCV]: time64 does not work on riscv32
2023-05-21 0:59 [Bug libc/30477] New: riscv32: time64 does not work tsu.yubo at gmail dot com
@ 2023-05-22 9:20 ` tsu.yubo at gmail dot com
2023-05-22 13:08 ` adhemerval.zanella at linaro dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tsu.yubo at gmail dot com @ 2023-05-22 9:20 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30477
Bo YU <tsu.yubo at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|riscv32: time64 does not |[RISCV]: time64 does not
|work |work on riscv32
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/30477] [RISCV]: time64 does not work on riscv32
2023-05-21 0:59 [Bug libc/30477] New: riscv32: time64 does not work tsu.yubo at gmail dot com
2023-05-22 9:20 ` [Bug libc/30477] [RISCV]: time64 does not work on riscv32 tsu.yubo at gmail dot com
@ 2023-05-22 13:08 ` adhemerval.zanella at linaro dot org
2023-05-30 11:54 ` adhemerval.zanella at linaro dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2023-05-22 13:08 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30477
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adhemerval.zanella at linaro dot o
| |rg
--- Comment #1 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
The issue is not that time64 does not work on riscv32, but rather we overlook
the fcntl-linux.h for 32 bit with 64 bit time_t default support (it defines the
old interface values, rather than the expected 64 bit time_t ones).
This patch below should fix it, although it is essentially a ABI break:
diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
index ca6a0d7516..3c15625599 100644
--- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
@@ -101,7 +101,7 @@
#endif
#ifndef F_GETLK
-# ifndef __USE_FILE_OFFSET64
+# if !defined(__USE_FILE_OFFSET64) && __TIMESIZE != 64
# define F_GETLK 5 /* Get record locking info. */
# define F_SETLK 6 /* Set record locking info (non-blocking). */
# define F_SETLKW 7 /* Set record locking info (blocking). */
I will send a fix upstream.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/30477] [RISCV]: time64 does not work on riscv32
2023-05-21 0:59 [Bug libc/30477] New: riscv32: time64 does not work tsu.yubo at gmail dot com
2023-05-22 9:20 ` [Bug libc/30477] [RISCV]: time64 does not work on riscv32 tsu.yubo at gmail dot com
2023-05-22 13:08 ` adhemerval.zanella at linaro dot org
@ 2023-05-30 11:54 ` adhemerval.zanella at linaro dot org
2023-06-01 6:54 ` tsu.yubo at gmail dot com
2023-06-02 0:59 ` sam at gentoo dot org
4 siblings, 0 replies; 6+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2023-05-30 11:54 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30477
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |adhemerval.zanella at linaro dot o
| |rg
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
Target Milestone|--- |2.38
--- Comment #2 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Fixed on 2.38
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/30477] [RISCV]: time64 does not work on riscv32
2023-05-21 0:59 [Bug libc/30477] New: riscv32: time64 does not work tsu.yubo at gmail dot com
` (2 preceding siblings ...)
2023-05-30 11:54 ` adhemerval.zanella at linaro dot org
@ 2023-06-01 6:54 ` tsu.yubo at gmail dot com
2023-06-02 0:59 ` sam at gentoo dot org
4 siblings, 0 replies; 6+ messages in thread
From: tsu.yubo at gmail dot com @ 2023-06-01 6:54 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30477
--- Comment #3 from Bo YU <tsu.yubo at gmail dot com> ---
Okay, many thanks.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/30477] [RISCV]: time64 does not work on riscv32
2023-05-21 0:59 [Bug libc/30477] New: riscv32: time64 does not work tsu.yubo at gmail dot com
` (3 preceding siblings ...)
2023-06-01 6:54 ` tsu.yubo at gmail dot com
@ 2023-06-02 0:59 ` sam at gentoo dot org
4 siblings, 0 replies; 6+ messages in thread
From: sam at gentoo dot org @ 2023-06-02 0:59 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30477
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gentoo dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-02 0:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-21 0:59 [Bug libc/30477] New: riscv32: time64 does not work tsu.yubo at gmail dot com
2023-05-22 9:20 ` [Bug libc/30477] [RISCV]: time64 does not work on riscv32 tsu.yubo at gmail dot com
2023-05-22 13:08 ` adhemerval.zanella at linaro dot org
2023-05-30 11:54 ` adhemerval.zanella at linaro dot org
2023-06-01 6:54 ` tsu.yubo at gmail dot com
2023-06-02 0:59 ` sam at gentoo dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).