Bug#851261: Info received (Bug#851261: duperemove FTBFS on mips and mipsel: error: undefined reference to `__sync_add_and_fetch_8')

2017-02-10 Thread Peter Zahradnik
patches were sent upstream and merged. I'm gonna prepare new package 
version and look into the process of backports.


regards,
Peter



Bug#851261: duperemove FTBFS on mips and mipsel: error: undefined reference to `__sync_add_and_fetch_8'

2017-01-15 Thread Peter Zahradnik

On 01/13/2017 01:23 PM, Radovan Birdic wrote:

Package: duperemove
Version: 0.11~beta4-1
Severity: important
Tags: sid + patch
Justification: FTBFS
User: debian-m...@lists.debian.org
Usertags: mips-patch

Hello,

Package duperemove_0.11~beta4-1 FTBFS on mips and mipsel with following error:


  file_scan.o: In function `csum_whole_file_init':
  ./file_scan.c:663: undefined reference to `__sync_add_and_fetch_8'
  ./file_scan.c:663: undefined reference to `__sync_add_and_fetch_8'
  run_dedupe.o: In function `dedupe_worker':
  ./run_dedupe.c:676: undefined reference to `__sync_add_and_fetch_8'
  run_dedupe.o: In function `extent_dedupe_worker':
  ./run_dedupe.c:479: undefined reference to `__sync_add_and_fetch_8'
  run_dedupe.o: In function `block_dedupe_worker':
  ./run_dedupe.c:656: undefined reference to `__sync_add_and_fetch_8'
  run_dedupe.o:./run_dedupe.c:801: more undefined references to 
`__sync_add_and_fetch_8' follow
  collect2: error: ld returned 1 exit status
  Makefile:82: recipe for target 'duperemove' failed
  make[1]: *** [duperemove] Error 1

Mips platform does not support 64-bit __sync_* operations,
instead we need to use corresponding __atomic_* operations.
Linking with latomic is also necessary for mips32 arches.

Patch use-atomic-instead-sync.patch replaces __sync_add_and_fetch with 
corresponding __atomic_fetch_add functions.
Patch linking-with-latomic-as-needed.patch adds linking with latomic library as 
needed.

With these patches, package builds successfully on mips, mipsel, mips64el and 
i386.

Regards,
Radovan

Hi Radovan,

thanks for report and for patches too! I'll include them asap.

Peter



Bug#851261: duperemove FTBFS on mips and mipsel: error: undefined reference to `__sync_add_and_fetch_8'

2017-01-13 Thread Radovan Birdic
Package: duperemove
Version: 0.11~beta4-1
Severity: important
Tags: sid + patch
Justification: FTBFS
User: debian-m...@lists.debian.org
Usertags: mips-patch

Hello,

Package duperemove_0.11~beta4-1 FTBFS on mips and mipsel with following error:

>  file_scan.o: In function `csum_whole_file_init':
>  ./file_scan.c:663: undefined reference to `__sync_add_and_fetch_8'
>  ./file_scan.c:663: undefined reference to `__sync_add_and_fetch_8'
>  run_dedupe.o: In function `dedupe_worker':
>  ./run_dedupe.c:676: undefined reference to `__sync_add_and_fetch_8'
>  run_dedupe.o: In function `extent_dedupe_worker':
>  ./run_dedupe.c:479: undefined reference to `__sync_add_and_fetch_8'
>  run_dedupe.o: In function `block_dedupe_worker':
>  ./run_dedupe.c:656: undefined reference to `__sync_add_and_fetch_8'
>  run_dedupe.o:./run_dedupe.c:801: more undefined references to 
> `__sync_add_and_fetch_8' follow
>  collect2: error: ld returned 1 exit status
>  Makefile:82: recipe for target 'duperemove' failed
>  make[1]: *** [duperemove] Error 1

Mips platform does not support 64-bit __sync_* operations, 
instead we need to use corresponding __atomic_* operations.
Linking with latomic is also necessary for mips32 arches.

Patch use-atomic-instead-sync.patch replaces __sync_add_and_fetch with 
corresponding __atomic_fetch_add functions.
Patch linking-with-latomic-as-needed.patch adds linking with latomic library as 
needed.

With these patches, package builds successfully on mips, mipsel, mips64el and 
i386.

Regards,
Radovan--- duperemove-0.11~beta4.orig/Makefile
+++ duperemove-0.11~beta4/Makefile
@@ -53,6 +53,7 @@ endif
 override CFLAGS += -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"$(RELEASE)\" \
 	$(hash_CFLAGS) $(glib_CFLAGS) $(sqlite_CFLAGS) -rdynamic $(DEBUG_FLAGS)
 LIBRARY_FLAGS += $(hash_LIBS) $(glib_LIBS) $(sqlite_LIBS) -lm
+LIBRARY_FLAGS += -Wl,--as-needed -latomic
 
 # make C=1 to enable sparse
 ifdef C
--- duperemove-0.11~beta4.orig/file_scan.c
+++ duperemove-0.11~beta4/file_scan.c
@@ -660,7 +660,7 @@ static void csum_whole_file_init(GMutex
 	unsigned long long cur_scan_files;
 	*mutex = g_dataset_get_data(location, "mutex");
 
-	cur_scan_files = __sync_add_and_fetch(&_cur_scan_files, 1);
+	cur_scan_files = __atomic_fetch_add(&_cur_scan_files, 1, __ATOMIC_SEQ_CST);
 
 	printf("[%0*llu/%llu] (%05.2f%%) csum: %s\n",
 	   leading_spaces, cur_scan_files, files_to_scan,
--- duperemove-0.11~beta4.orig/run_dedupe.c
+++ duperemove-0.11~beta4/run_dedupe.c
@@ -476,7 +476,7 @@ static int extent_dedupe_worker(struct d
 uint64_t *fiemap_bytes, uint64_t *kern_bytes)
 {
 	int ret;
-	unsigned long long passno = __sync_add_and_fetch(&curr_dedupe_pass, 1);
+	unsigned long long passno = __atomic_fetch_add(&curr_dedupe_pass, 1, __ATOMIC_SEQ_CST);
 
 	ret = dedupe_extent_list(dext, fiemap_bytes, kern_bytes, passno);
 	if (ret) {
@@ -653,7 +653,7 @@ static int block_dedupe_worker(struct bl
 {
 	int ret;
 	struct results_tree res;
-	unsigned long long passno = __sync_add_and_fetch(&curr_dedupe_pass, 1);
+	unsigned long long passno =  __atomic_fetch_add(&curr_dedupe_pass, 1, __ATOMIC_SEQ_CST);
 
 	init_results_tree(&res);
 
@@ -798,8 +798,8 @@ static int __push_blocks(struct hash_tre
 		goto out;
 	bdl = NULL;
 
-	__sync_add_and_fetch(
-		&total_dedupe_passes, 1);
+	 __atomic_fetch_add(
+		&total_dedupe_passes, 1, __ATOMIC_SEQ_CST);
 	break;
 }
 			}