Package: proot
Severity: minor
Usertags: clang-ftbfs
User: [email protected]
Tag: patch


Hello,

Using the rebuild infrastructure, your package fails to build with clang
(instead of gcc).

Thanks,
Arthur
diff -Naur proot.orig/proot-3.2.2/debian/changelog proot/proot-3.2.2/debian/changelog
--- proot.orig/proot-3.2.2/debian/changelog	2014-06-07 18:21:54.313798503 -0500
+++ proot/proot-3.2.2/debian/changelog	2014-06-07 18:54:27.789832522 -0500
@@ -1,3 +1,15 @@
+proot (3.2.2-2) unstable; urgency=low
+
+  * Fix FTBFS with clang
+    - Fixed "function definition not allowed" error in
+    src/cli/cli.c
+    src/execve/elf.c
+    src/path/path.c
+    src/tracee/event.c
+    src/tracee/tracee.c
+  
+ -- Arthur Marble <[email protected]>  Sat, 07 Jun 2014 18:54:19 -0500
+
 proot (3.2.2-1) unstable; urgency=low
 
   * Upgrade to latest PRoot version (Closes: #730363)
diff -Naur proot.orig/proot-3.2.2/debian/patches/clang-ftbfs.diff proot/proot-3.2.2/debian/patches/clang-ftbfs.diff 
--- proot.orig/proot-3.2.2/debian/patches/clang-ftbfs.diff	1969-12-31 18:00:00.000000000 -0600
+++ proot/proot-3.2.2/debian/patches/clang-ftbfs.diff	2014-06-07 18:58:21.345836589 -0500
@@ -0,0 +1,320 @@
+--- a/src/cli/cli.c
++++ b/src/cli/cli.c
+@@ -145,6 +145,13 @@ static void print_error_separator(const
+ 			argument->name, argument->separator);
+ }
+ 
++static void append(const char *post, char string[]) {
++	ssize_t length = sizeof(string) - (strlen(string) + strlen(post));
++	if (length <= 0)
++		return;
++	strncat(string, post, length);
++}
++
+ static void print_argv(const Tracee *tracee, const char *prompt, char **argv)
+ {
+ 	char string[ARG_MAX] = "";
+@@ -153,18 +160,11 @@ static void print_argv(const Tracee *tra
+ 	if (!argv)
+ 		return;
+ 
+-	void append(const char *post) {
+-		ssize_t length = sizeof(string) - (strlen(string) + strlen(post));
+-		if (length <= 0)
+-			return;
+-		strncat(string, post, length);
+-	}
+-
+-	append(prompt);
+-	append(" =");
++	append(prompt, string);
++	append(" =", string);
+ 	for (i = 0; argv[i] != NULL; i++) {
+-		append(" ");
+-		append(argv[i]);
++		append(" ", string);
++		append(argv[i], string);
+ 	}
+ 	string[sizeof(string) - 1] = '\0';
+ 
+--- a/src/execve/elf.c
++++ b/src/execve/elf.c
+@@ -311,6 +311,31 @@ static int add_xpaths(const Tracee *trac
+ 	return 0;
+ }
+ 
++/* Callback used to get the address of the *first* string
++ * table.  The ELF specification doesn't mention if it may
++ * have several string table references.  */
++static int get_strtab_address(uint64_t value, uint64_t strtab_address)
++{
++	strtab_address = value;
++	return -1; /* Stop the loop.  */
++}
++
++static int add_rpaths(uint64_t index, off_t strtab_offset, const Tracee* tracee,
++	       int fd, char **rpaths)
++{
++	if (strtab_offset < 0 || (uint64_t) strtab_offset > UINT64_MAX - index)
++		return -ENOEXEC;
++	return add_xpaths(tracee, fd, strtab_offset + index, rpaths);
++}
++
++static int add_runpaths(uint64_t index, off_t strtab_offset, const Tracee* tracee,
++		 int fd, char **runpaths)
++{
++	if (strtab_offset < 0 || (uint64_t) strtab_offset > UINT64_MAX - index)
++		return -ENOEXEC;
++	return add_xpaths(tracee, fd, strtab_offset + index, runpaths);
++}
++
+ /**
+  * Put the RPATH and RUNPATH dynamic entries from the file referenced
+  * by @fd -- which has the provided @elf_header -- in @rpaths and
+@@ -330,15 +355,6 @@ int read_ldso_rpaths(const Tracee* trace
+ 	if (status <= 0)
+ 		return status;
+ 
+-	/* Callback used to get the address of the *first* string
+-	 * table.  The ELF specification doesn't mention if it may
+-	 * have several string table references.  */
+-	int get_strtab_address(uint64_t value)
+-	{
+-		strtab_address = value;
+-		return -1; /* Stop the loop.  */
+-	}
+-
+ 	status = foreach_dynamic_entry(fd, elf_header, &dynamic, DT_STRTAB, get_strtab_address);
+ 	if (strtab_address == (uint64_t) -1) {
+ 		if (status < 0)
+@@ -356,20 +372,6 @@ int read_ldso_rpaths(const Tracee* trace
+ 	strtab_offset = PROGRAM_FIELD(*elf_header, strtab_segment, offset)
+ 		+ (strtab_address - PROGRAM_FIELD(*elf_header, strtab_segment, vaddr));
+ 
+-	int add_rpaths(uint64_t index)
+-	{
+-		if (strtab_offset < 0 || (uint64_t) strtab_offset > UINT64_MAX - index)
+-			return -ENOEXEC;
+-		return add_xpaths(tracee, fd, strtab_offset + index, rpaths);
+-	}
+-
+-	int add_runpaths(uint64_t index)
+-	{
+-		if (strtab_offset < 0 || (uint64_t) strtab_offset > UINT64_MAX - index)
+-			return -ENOEXEC;
+-		return add_xpaths(tracee, fd, strtab_offset + index, runpaths);
+-	}
+-
+ 	status = foreach_dynamic_entry(fd, elf_header, &dynamic, DT_RPATH, add_rpaths);
+ 	if (status < 0)
+ 		return status;
+--- a/src/path/path.c
++++ b/src/path/path.c
+@@ -706,19 +706,20 @@ end:
+ 	return status;
+ }
+ 
++static int list_open_fd_callback(const Tracee *tracee, int fd, char path[PATH_MAX])
++{
++	VERBOSE(tracee, 1,
++		"pid %d: access to \"%s\" (fd %d) won't be translated until closed",
++		tracee->pid, path, fd);
++	return 0;
++}
++
+ /**
+  * Warn for files that are open. It is useful right after PRoot has
+  * attached a process.
+  */
+ int list_open_fd(const Tracee *tracee)
+ {
+-	int list_open_fd_callback(const Tracee *tracee, int fd, char path[PATH_MAX])
+-	{
+-		VERBOSE(tracee, 1,
+-			"pid %d: access to \"%s\" (fd %d) won't be translated until closed",
+-			tracee->pid, path, fd);
+-		return 0;
+-	}
+ 	return foreach_fd(tracee, list_open_fd_callback);
+ }
+ 
+--- a/src/tracee/tracee.c
++++ b/src/tracee/tracee.c
+@@ -256,6 +256,23 @@ int new_child(Tracee *parent, word_t clo
+ 	return 0;
+ }
+ 
++static void reparent_config(Tracee *new_parent, Tracee *old_parent) {
++	new_parent->verbose = old_parent->verbose;
++	new_parent->qemu_pie_workaround = old_parent->qemu_pie_workaround;
++
++	#define REPARENT(field) do {						\
++		talloc_reparent(old_parent, new_parent, old_parent->field);	\
++		new_parent->field = old_parent->field;				\
++	} while(0);
++
++	REPARENT(fs);
++	REPARENT(exe);
++	REPARENT(cmdline);
++	REPARENT(qemu);
++	REPARENT(glue);
++	REPARENT(extensions);
++}
++
+ /**
+  * Swap configuration (pointers and parentality) between @tracee1 and @tracee2.
+  */
+@@ -268,23 +285,6 @@ int swap_config(Tracee *tracee1, Tracee
+ 		return -ENOMEM;
+ 
+ #if defined(TALLOC_VERSION_MAJOR) && TALLOC_VERSION_MAJOR >= 2
+-	void reparent_config(Tracee *new_parent, Tracee *old_parent) {
+-		new_parent->verbose = old_parent->verbose;
+-		new_parent->qemu_pie_workaround = old_parent->qemu_pie_workaround;
+-
+-		#define REPARENT(field) do {						\
+-			talloc_reparent(old_parent, new_parent, old_parent->field);	\
+-			new_parent->field = old_parent->field;				\
+-		} while(0);
+-
+-		REPARENT(fs);
+-		REPARENT(exe);
+-		REPARENT(cmdline);
+-		REPARENT(qemu);
+-		REPARENT(glue);
+-		REPARENT(extensions);
+-	}
+-
+ 	reparent_config(tmp,     tracee1);
+ 	reparent_config(tracee1, tracee2);
+ 	reparent_config(tracee2, tmp);
+--- a/src/tracee/event.c
++++ b/src/tracee/event.c
+@@ -129,69 +129,69 @@ static void kill_all_tracees2(int signum
+ 		_exit(EXIT_FAILURE);
+ }
+ 
+-/* Print on stderr the complete talloc hierarchy.  */
+-static void print_talloc_hierarchy(int signum, siginfo_t *siginfo UNUSED, void *ucontext UNUSED)
++static void print_talloc_chunk(const void *ptr, int depth, int max_depth UNUSED,
++			int is_ref, void *data UNUSED)
+ {
+-	void print_talloc_chunk(const void *ptr, int depth, int max_depth UNUSED,
+-				int is_ref, void *data UNUSED)
+-	{
+-		const char *name;
+-		size_t count;
+-		size_t size;
+-
+-		name = talloc_get_name(ptr);
+-		size = talloc_get_size(ptr);
+-		count = talloc_reference_count(ptr);
+-
+-		if (depth == 0)
+-			return;
+-
+-		while (depth-- > 1)
+-			fprintf(stderr, "\t");
+-
+-		fprintf(stderr, "%-16s ", name);
+-
+-		if (is_ref)
+-			fprintf(stderr, "-> %-8p", ptr);
+-		else {
+-			fprintf(stderr, "%-8p  %zd bytes  %zd ref'", ptr, size, count);
+-
+-			if (name[0] == '$') {
+-				fprintf(stderr, "\t(\"%s\")", (char *)ptr);
+-			}
+-			if (name[0] == '@') {
+-				char **argv;
+-				int i;
+-
+-				fprintf(stderr, "\t(");
+-				for (i = 0, argv = (char **)ptr; argv[i] != NULL; i++)
+-					fprintf(stderr, "\"%s\", ", argv[i]);
+-				fprintf(stderr, ")");
+-			}
+-			else if (strcmp(name, "Tracee") == 0) {
+-				fprintf(stderr, "\t(pid = %d)", ((Tracee *)ptr)->pid);
+-			}
+-			else if (strcmp(name, "Bindings") == 0) {
+-				 Tracee *tracee;
+-
+-				 tracee = TRACEE(ptr);
+-
+-				 if (ptr == tracee->fs->bindings.pending)
+-					 fprintf(stderr, "\t(pending)");
+-				 else if (ptr == tracee->fs->bindings.guest)
+-					 fprintf(stderr, "\t(guest)");
+-				 else if (ptr == tracee->fs->bindings.host)
+-					 fprintf(stderr, "\t(host)");
+-			}
+-			else if (strcmp(name, "Binding") == 0) {
+-				Binding *binding = (Binding *)ptr;
+-				fprintf(stderr, "\t(%s:%s)", binding->host.path, binding->guest.path);
+-			}
++	const char *name;
++	size_t count;
++	size_t size;
++
++	name = talloc_get_name(ptr);
++	size = talloc_get_size(ptr);
++	count = talloc_reference_count(ptr);
++
++	if (depth == 0)
++		return;
++
++	while (depth-- > 1)
++		fprintf(stderr, "\t");
++
++	fprintf(stderr, "%-16s ", name);
++
++	if (is_ref)
++		fprintf(stderr, "-> %-8p", ptr);
++	else {
++		fprintf(stderr, "%-8p  %zd bytes  %zd ref'", ptr, size, count);
++
++		if (name[0] == '$') {
++			fprintf(stderr, "\t(\"%s\")", (char *)ptr);
++		}
++		if (name[0] == '@') {
++			char **argv;
++			int i;
++
++			fprintf(stderr, "\t(");
++			for (i = 0, argv = (char **)ptr; argv[i] != NULL; i++)
++				fprintf(stderr, "\"%s\", ", argv[i]);
++			fprintf(stderr, ")");
+ 		}
++		else if (strcmp(name, "Tracee") == 0) {
++			fprintf(stderr, "\t(pid = %d)", ((Tracee *)ptr)->pid);
++		}
++		else if (strcmp(name, "Bindings") == 0) {
++			 Tracee *tracee;
++
++			 tracee = TRACEE(ptr);
+ 
+-		fprintf(stderr, "\n");
++			 if (ptr == tracee->fs->bindings.pending)
++				 fprintf(stderr, "\t(pending)");
++			 else if (ptr == tracee->fs->bindings.guest)
++				 fprintf(stderr, "\t(guest)");
++			 else if (ptr == tracee->fs->bindings.host)
++				 fprintf(stderr, "\t(host)");
++		}
++		else if (strcmp(name, "Binding") == 0) {
++			Binding *binding = (Binding *)ptr;
++			fprintf(stderr, "\t(%s:%s)", binding->host.path, binding->guest.path);
++		}
+ 	}
+ 
++	fprintf(stderr, "\n");
++}
++
++/* Print on stderr the complete talloc hierarchy.  */
++static void print_talloc_hierarchy(int signum, siginfo_t *siginfo UNUSED, void *ucontext UNUSED)
++{
+ 	switch (signum) {
+ 	case SIGUSR1:
+ 		talloc_report_depth_cb(NULL, 0, 100, print_talloc_chunk, NULL);
diff -Naur proot.orig/proot-3.2.2/debian/patches/series proot/proot-3.2.2/debian/patches/series 
--- proot.orig/proot-3.2.2/debian/patches/series	2014-06-07 18:21:54.313798503 -0500
+++ proot/proot-3.2.2/debian/patches/series	2014-06-07 18:22:03.925798670 -0500
@@ -1 +1,2 @@
 Install-proot-into-DESTDIR-usr-bin.patch
+clang-ftbfs.diff

Reply via email to