Thread overview
Re: Sort order of dirEntries
Oct 25, 2012
H. S. Teoh
Oct 25, 2012
H. S. Teoh
Oct 25, 2012
H. S. Teoh
Re: GDC build [was: Re: Sort order of dirEntries]
Oct 25, 2012
H. S. Teoh
October 25, 2012
On Thu, Oct 25, 2012 at 02:15:06AM +0200, Joseph Rushton Wakeling wrote:
> Hello all,
> 
> I've just been playing with dirEntries and by the looks of it, it returns these entries in arbitrary order.
> 
> Is there a way to get it to sort the entries in alphabetical order, other than the obvious one of storing them in an array and sorting that?  (This is untenable because I'm talking about a lot of files...:-)
[...]

This may not be possible if the OS doesn't keep the entries in sorted order (and from what I know, most OS's don't; it's only sorted upon display). *Somebody* will have to do the sorting, whether it's the OS, or the library or user code. The performance penalty will still be incurred regardless.


T

-- 
Don't drink and derive. Alcohol and algebra don't mix.
October 25, 2012
On 10/25/2012 02:30 AM, H. S. Teoh wrote:
> This may not be possible if the OS doesn't keep the entries in sorted
> order (and from what I know, most OS's don't; it's only sorted upon
> display). *Somebody* will have to do the sorting, whether it's the OS,
> or the library or user code. The performance penalty will still be
> incurred regardless.

... and interestingly enough the sort order seems to be different depending on the choice of compiler.

October 25, 2012
On Thu, Oct 25, 2012 at 04:22:43PM +0200, Joseph Rushton Wakeling wrote:
> On 10/25/2012 02:30 AM, H. S. Teoh wrote:
> >This may not be possible if the OS doesn't keep the entries in sorted order (and from what I know, most OS's don't; it's only sorted upon display). *Somebody* will have to do the sorting, whether it's the OS, or the library or user code. The performance penalty will still be incurred regardless.
> 
> ... and interestingly enough the sort order seems to be different depending on the choice of compiler.

Oh, really? I couldn't reproduce that effect on my system (Debian Linux
64-bit) with dmd (latest git) and gdc (git gdc-4.7 branch). I always get
the same ordering regardless of the compiler I used.

For reference, here's my code:

	import std.file;
	import std.stdio;

	void main(string[] args) {
		auto entries = dirEntries(args.length > 1 ? args[1] : ".",
					SpanMode.shallow);

		foreach (e; entries) {
			writeln(e);
		}
	}


T

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.
October 25, 2012
On 10/25/2012 07:17 PM, H. S. Teoh wrote:
> Oh, really? I couldn't reproduce that effect on my system (Debian Linux
> 64-bit) with dmd (latest git) and gdc (git gdc-4.7 branch). I always get
> the same ordering regardless of the compiler I used.

No, I think you're right; I'd been filtering dirEntries through takeExactly and it was generating an error using dmd.

That reminds me -- did you tweak the GDC wiki to add the info about patching the GCC sources?  I must get a working gdc-4.7 on my system.

October 25, 2012
On Thu, Oct 25, 2012 at 09:06:12PM +0200, Joseph Rushton Wakeling wrote: [...]
> That reminds me -- did you tweak the GDC wiki to add the info about patching the GCC sources?  I must get a working gdc-4.7 on my system.

Yeah I've updated the wiki (http://gdcproject.org/wiki/Installation).

No guarantees that it will work, though. The GCC build system is a fragile, sensitive animal.


T

-- 
Some ideas are so stupid that only intellectuals could believe them. -- George Orwell
October 25, 2012
On 10/25/2012 10:07 PM, H. S. Teoh wrote:
> No guarantees that it will work, though. The GCC build system is a
> fragile, sensitive animal.

Indeed ... having followed your instructions (on 64-bit Ubuntu 12.10) I found myself first faced with the "cannot find crti.o" I'd encountered before.

I "fixed" that by Alex Petersen's suggestion of symlinking /usr/lib/x86_64-linux-gnu/crt*.o to /usr/lib/crt*.o (which hopefully won't break anything) and the build proceeded on that basis, but finally fell over with another error, I think while trying to build gcov-dump (it's a bit hard to tell with such verbose compilation statements as GCC has):

------------------------------------------------------------------------------
d/d-gcc.o: In function `used_arg':
gcc.c:(.text+0xdf4): undefined reference to `fatal_error'
d/d-gcc.o: In function `compare_version_strings':
gcc.c:(.text+0xf4a): undefined reference to `fancy_abort'
gcc.c:(.text+0xf5e): undefined reference to `fancy_abort'
gcc.c:(.text+0xf6d): undefined reference to `fatal_error'
gcc.c:(.text+0xf81): undefined reference to `fancy_abort'
gcc.c:(.text+0xf90): undefined reference to `fatal_error'
d/d-gcc.o: In function `version_compare_spec_function':
gcc.c:(.text+0x1120): undefined reference to `fatal_error'
gcc.c:(.text+0x1238): undefined reference to `fatal_error'
gcc.c:(.text+0x124c): undefined reference to `fancy_abort'
gcc.c:(.text+0x1258): undefined reference to `fatal_error'
d/d-gcc.o: In function `compare_debug_auxbase_opt_spec_function':
gcc.c:(.text+0x143c): undefined reference to `fatal_error'
gcc.c:(.text+0x1448): undefined reference to `fatal_error'
gcc.c:(.text+0x1454): undefined reference to `fatal_error'
d/d-gcc.o: In function `xputenv':
gcc.c:(.text+0x1762): undefined reference to `fnotice'
d/d-gcc.o: In function `find_plugindir_spec_function':
gcc.c:(.text+0x2497): undefined reference to `fancy_abort'
d/d-gcc.o: In function `find_file_spec_function':
gcc.c:(.text+0x24bb): undefined reference to `fancy_abort'
d/d-gcc.o: In function `remove_outfile_spec_function':
gcc.c:(.text+0x2532): undefined reference to `fancy_abort'
d/d-gcc.o: In function `replace_outfile_spec_function':
gcc.c:(.text+0x25dd): undefined reference to `fancy_abort'
d/d-gcc.o: In function `getenv_spec_function':
gcc.c:(.text+0x2677): undefined reference to `fatal_error'
d/d-gcc.o: In function `process_command':
gcc.c:(.text+0x2c62): undefined reference to `common_handle_option'
gcc.c:(.text+0x2c71): undefined reference to `target_handle_option'
gcc.c:(.text+0x2dda): undefined reference to `read_cmdline_option'
gcc.c:(.text+0x2ffb): undefined reference to `warning'
gcc.c:(.text+0x3111): undefined reference to `warning'
gcc.c:(.text+0x322a): undefined reference to `fancy_abort'
d/d-gcc.o: In function `retry_ice':
gcc.c:(.text+0x381b): undefined reference to `fnotice'
gcc.c:(.text+0x3b32): undefined reference to `fnotice'
d/d-gcc.o: In function `add_sysrooted_prefix.constprop.20':
gcc.c:(.text+0x3d72): undefined reference to `fatal_error'
d/d-gcc.o: In function `init_spec.part.4':
gcc.c:(.text+0x4184): undefined reference to `fnotice'
d/d-gcc.o: In function `add_linker_option':
gcc.c:(.text+0x4326): undefined reference to `vec_heap_p_reserve'
d/d-gcc.o: In function `add_preprocessor_option':
gcc.c:(.text+0x4386): undefined reference to `vec_heap_p_reserve'
d/d-gcc.o: In function `add_assembler_option':
gcc.c:(.text+0x43e6): undefined reference to `vec_heap_p_reserve'
d/d-gcc.o: In function `driver_handle_option':
gcc.c:(.text+0x4cde): undefined reference to `fancy_abort'
gcc.c:(.text+0x4da9): undefined reference to `fancy_abort'
gcc.c:(.text+0x4dbd): undefined reference to `fancy_abort'
gcc.c:(.text+0x4dd1): undefined reference to `fancy_abort'
gcc.c:(.text+0x4de5): undefined reference to `fancy_abort'
d/d-gcc.o:gcc.c:(.text+0x4df9): more undefined references to `fancy_abort' follow
d/d-gcc.o: In function `driver_handle_option':
gcc.c:(.text+0x4e31): undefined reference to `fatal_error'
d/d-gcc.o: In function `store_arg':
gcc.c:(.text+0x4f8d): undefined reference to `vec_heap_p_reserve'
d/d-gcc.o: In function `create_at_file':
gcc.c:(.text+0x5214): undefined reference to `fatal_error'
gcc.c:(.text+0x5223): undefined reference to `fatal_error'
gcc.c:(.text+0x5232): undefined reference to `fatal_error'
d/d-gcc.o: In function `execute':
gcc.c:(.text+0x5666): undefined reference to `fatal_error'
gcc.c:(.text+0x591c): undefined reference to `vec_heap_p_reserve'
gcc.c:(.text+0x59b8): undefined reference to `vec_heap_p_reserve_exact'
gcc.c:(.text+0x5e36): undefined reference to `fnotice'
gcc.c:(.text+0x5f58): undefined reference to `fancy_abort'
gcc.c:(.text+0x5f62): undefined reference to `fatal_error'
gcc.c:(.text+0x5f8a): undefined reference to `fancy_abort'
gcc.c:(.text+0x5fc1): undefined reference to `fatal_error'
gcc.c:(.text+0x5fe4): undefined reference to `internal_error'
gcc.c:(.text+0x5fee): undefined reference to `fatal_error'
d/d-gcc.o: In function `do_spec_1':
gcc.c:(.text+0x669f): undefined reference to `fatal_error'
gcc.c:(.text+0x69e0): undefined reference to `fatal_error'
gcc.c:(.text+0x6d6a): undefined reference to `inform'
gcc.c:(.text+0x75fa): undefined reference to `fatal_error'
gcc.c:(.text+0x7ad8): undefined reference to `vec_heap_p_reserve_exact'
gcc.c:(.text+0x7d50): undefined reference to `fatal_error'
gcc.c:(.text+0x7d66): undefined reference to `fatal_error'
gcc.c:(.text+0x7d97): undefined reference to `fatal_error'
gcc.c:(.text+0x7da6): undefined reference to `fatal_error'
gcc.c:(.text+0x7dba): undefined reference to `fatal_error'
d/d-gcc.o:gcc.c:(.text+0x7dd5): more undefined references to `fatal_error' follow
d/d-gcc.o: In function `compare_debug_dump_opt_spec_function':
gcc.c:(.text+0x8b5a): undefined reference to `fancy_abort'
d/d-gcc.o: In function `do_self_spec':
gcc.c:(.text+0x8d49): undefined reference to `decode_cmdline_options_to_array'
gcc.c:(.text+0x8d83): undefined reference to `common_handle_option'
gcc.c:(.text+0x8d94): undefined reference to `target_handle_option'
gcc.c:(.text+0x8e4f): undefined reference to `read_cmdline_option'
gcc.c:(.text+0x8e78): undefined reference to `fatal_error'
gcc.c:(.text+0x8e88): undefined reference to `fatal_error'
d/d-gcc.o: In function `read_specs':
gcc.c:(.text+0x90a8): undefined reference to `fnotice'
gcc.c:(.text+0x91e4): undefined reference to `fatal_error'
gcc.c:(.text+0x9784): undefined reference to `fnotice'
gcc.c:(.text+0x97ae): undefined reference to `fatal_error'
gcc.c:(.text+0x97da): undefined reference to `fnotice'
gcc.c:(.text+0x9809): undefined reference to `fatal_error'
gcc.c:(.text+0x9831): undefined reference to `fatal_error'
gcc.c:(.text+0x9848): undefined reference to `fatal_error'
gcc.c:(.text+0x9864): undefined reference to `fatal_error'
gcc.c:(.text+0x9873): undefined reference to `fatal_error'
d/d-gcc.o:gcc.c:(.text+0x9888): more undefined references to `fatal_error' follow
d/d-gcc.o: In function `include_spec_function':
gcc.c:(.text+0x9929): undefined reference to `fancy_abort'
d/d-gcc.o:(.rodata+0x4e8): undefined reference to `host_detect_local_cpu'
d/d-gcc.o: In function `main':
gcc.c:(.text.startup+0x97): undefined reference to `global_init_params'
gcc.c:(.text.startup+0x9c): undefined reference to `finish_params'
gcc.c:(.text.startup+0xab): undefined reference to `init_options_struct'
gcc.c:(.text.startup+0xd0): undefined reference to `decode_cmdline_options_to_array'
gcc.c:(.text.startup+0xda): undefined reference to `gcc_init_libintl'
gcc.c:(.text.startup+0xe8): undefined reference to `diagnostic_initialize'
gcc.c:(.text.startup+0x1b8): undefined reference to `vec_heap_p_reserve_exact'
gcc.c:(.text.startup+0x104e): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x153a): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x15d7): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x1b22): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x1ce5): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x1d25): undefined reference to `seen_error'
gcc.c:(.text.startup+0x1d44): undefined reference to `seen_error'
gcc.c:(.text.startup+0x1f42): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x1f5a): undefined reference to `fnotice'
gcc.c:(.text.startup+0x1f72): undefined reference to `fnotice'
gcc.c:(.text.startup+0x1f8a): undefined reference to `fnotice'
gcc.c:(.text.startup+0x2771): undefined reference to `fnotice'
gcc.c:(.text.startup+0x28f4): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x29c1): undefined reference to `inform'
gcc.c:(.text.startup+0x2a7a): undefined reference to `inform'
gcc.c:(.text.startup+0x2c40): undefined reference to `fancy_abort'
gcc.c:(.text.startup+0x2dd5): undefined reference to `seen_error'
gcc.c:(.text.startup+0x2e36): undefined reference to `seen_error'
gcc.c:(.text.startup+0x2e50): undefined reference to `seen_error'
gcc.c:(.text.startup+0x2ea8): undefined reference to `warning'
gcc.c:(.text.startup+0x2fa9): undefined reference to `seen_error'
gcc.c:(.text.startup+0x3118): undefined reference to `fatal_error'
gcc.c:(.text.startup+0x31b7): undefined reference to `fnotice'
d/d-spec.o: In function `lang_specific_driver':
d-spec.c:(.text+0x459): undefined reference to `generate_option'
d-spec.c:(.text+0x474): undefined reference to `generate_option_input_file'
d-spec.c:(.text+0x4e6): undefined reference to `generate_option'
d-spec.c:(.text+0x8ca): undefined reference to `generate_option'
d-spec.c:(.text+0x92e): undefined reference to `generate_option'
d-spec.c:(.text+0x98d): undefined reference to `generate_option'
d-spec.c:(.text+0xb3e): undefined reference to `generate_option'
d/d-spec.o:d-spec.c:(.text+0xc2f): more undefined references to `generate_option' follow
collect2: error: ld returned 1 exit status
make[3]: *** [gdc] Error 1
------------------------------------------------------------------------------

Any thoughts or advice?
October 25, 2012
On Thu, Oct 25, 2012 at 11:08:48PM +0200, Joseph Rushton Wakeling wrote:
> On 10/25/2012 10:07 PM, H. S. Teoh wrote:
> >No guarantees that it will work, though. The GCC build system is a fragile, sensitive animal.
> 
> Indeed ... having followed your instructions (on 64-bit Ubuntu 12.10) I found myself first faced with the "cannot find crti.o" I'd encountered before.

Oh? Did you run the debian/rules patch command in the package source directory? That was supposed to have fixed this issue, and potentially the issue you're seeing below (Debian-based systems break several assumptions that the GCC build system makese, so you really want to be applying the Debian patches to increase your odds of the build succeeding).


> I "fixed" that by Alex Petersen's suggestion of symlinking /usr/lib/x86_64-linux-gnu/crt*.o to /usr/lib/crt*.o (which hopefully won't break anything) and the build proceeded on that basis, but finally fell over with another error, I think while trying to build gcov-dump (it's a bit hard to tell with such verbose compilation statements as GCC has):

Hmm. Frankly, I have no idea what's going on here. :-( I myself am facing an error where gdc git HEAD isn't building because Walter's .c C++ files are getting compiled with gcc, and failing horribly 'cos it's C++, not C. According to Iain, this isn't supposed to happen, but I still have no idea why it's happening.

What parameters did you pass to configure? I wonder if you can turn off some stuff that you don't need, that might avoid this problem. I know that for me, I have to use --disable-multilib (at least), otherwise the build will fail. I also have --disable-gomp and --disable-quadmath, since neither are used by GDC. I'm not sure if they're related to your issue though.


T

-- 
It is widely believed that reinventing the wheel is a waste of time; but I disagree: without wheel reinventers, we would be still be stuck with wooden horse-cart wheels.
October 25, 2012
On 10/25/2012 11:22 PM, H. S. Teoh wrote:
> Oh? Did you run the debian/rules patch command in the package source
> directory? That was supposed to have fixed this issue, and potentially
> the issue you're seeing below (Debian-based systems break several
> assumptions that the GCC build system makese, so you really want to be
> applying the Debian patches to increase your odds of the build
> succeeding).

Yup.  Latest gdc-4.7 sources (which I believe include your patch), GCC 4.7.2 sources from the Ubuntu 12.10 repositories, tweaked the debian/rules.patch file as instructed, ran the debian/rules clean and debian/rules patch functions and update-gcc.sh.

I don't see anything in rules.patch that would get the compiler looking for crtio.o in /usr/lib/x86_64-linux-gnu/ though.

> What parameters did you pass to configure? I wonder if you can turn off
> some stuff that you don't need, that might avoid this problem. I know
> that for me, I have to use --disable-multilib (at least), otherwise the
> build will fail. I also have --disable-gomp and --disable-quadmath,
> since neither are used by GDC. I'm not sure if they're related to your
> issue though.

Originally I tried with --enable-language=d --disable-multilib --enable-lto. I've since tried without the -lto option, and tried disabling all the parts that are not used by GDC (gomp, quadmath, etc.)  Same error. :-(

It's really very, very frustrating, especially when compared to how easy it is to build LDC from source.  Even more so because it gets in the way of being able to actually help and contribute to GDC.