Thank you for your comments.
In my usage, it works good by the patch appended to this mail.
On May 24, 2010, at 2:49 AM, pluknet wrote:
On 24 May 2010 08:49, Kohji Okuno okuno.ko...@jp.panasonic.com wrote:
Hi all,
I want to compile 32bit binary on amd64, but I met with the problem.
Could you teach me the best solution, please?
My environment is FreeBSD 8.1-PRERELEASE #0: Tue May 18 12:01:26 JST 2010.
I compiled and executed test.c as below on amd64.
[...]
% gcc -m32 -B/usr/lib32 test.c
% ./a.out
mmap: Invalid argument
AFAIK, it still doesn't work on FreeBSD. You need something like 32bit
chroot environment.
There's also about:
http://www.freebsd.org/projects/ideas/#p-freebsd-amd64-gcc-m32
-m32 is busted on FreeBSD; I don't remember the full details but I think it
had something to do with the linking stage of things...
Thanks,
-Garrett
diff -Nur machine.org/_inttypes.h machine/_inttypes.h
--- machine.org/_inttypes.h 2009-08-03 17:13:06.0 +0900
+++ machine/_inttypes.h 2010-05-24 10:16:12.130753024 +0900
@@ -37,6 +37,9 @@
* $FreeBSD: src/sys/amd64/include/_inttypes.h,v 1.3.34.1 2009/08/03 08:13:06 kensmith Exp $
*/
+#ifdef __i386__
+#include machine/_inttypes32.h
+#else
#ifndef _MACHINE_INTTYPES_H_
#define _MACHINE_INTTYPES_H_
@@ -218,3 +221,4 @@
#define SCNxPTR lx /* uintptr_t */
#endif /* !_MACHINE_INTTYPES_H_ */
+#endif /* __i386__ */
diff -Nur machine.org/_inttypes32.h machine/_inttypes32.h
--- machine.org/_inttypes32.h 1970-01-01 09:00:00.0 +0900
+++ machine/_inttypes32.h 2010-05-24 10:17:17.382704652 +0900
@@ -0,0 +1,220 @@
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *must display the following acknowledgement:
+ *This product includes software developed by the NetBSD
+ *Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $
+ * $FreeBSD: src/sys/i386/include/_inttypes.h,v 1.2.36.1 2009/08/03 08:13:06 kensmith Exp $
+ */
+
+#ifndef _MACHINE_INTTYPES_H_
+#define _MACHINE_INTTYPES_H_
+
+/*
+ * Macros for format specifiers.
+ */
+
+/* fprintf(3) macros for signed integers. */
+
+#define PRId8 d /* int8_t */
+#define PRId16 d /* int16_t */
+#define PRId32 d /* int32_t */
+#define PRId64 lld /* int64_t */
+#define PRIdLEAST8 d /* int_least8_t */
+#define PRIdLEAST16 d /* int_least16_t */
+#define PRIdLEAST32 d /* int_least32_t */
+#define PRIdLEAST64 lld /* int_least64_t */
+#define PRIdFAST8 d /* int_fast8_t */
+#define PRIdFAST16 d /* int_fast16_t */
+#define PRIdFAST32 d /* int_fast32_t */
+#define PRIdFAST64 lld /* int_fast64_t */
+#define PRIdMAX jd /* intmax_t */
+#define PRIdPTR d /* intptr_t */
+
+#define PRIi8 i /* int8_t */
+#define PRIi16 i /* int16_t */
+#define PRIi32 i /* int32_t */
+#define PRIi64 lli /* int64_t */
+#define PRIiLEAST8 i /* int_least8_t */
+#define PRIiLEAST16 i /* int_least16_t */
+#define PRIiLEAST32 i /* int_least32_t */
+#define PRIiLEAST64 lli /* int_least64_t */
+#define PRIiFAST8 i /* int_fast8_t */
+#define PRIiFAST16 i /* int_fast16_t */
+#define PRIiFAST32 i /* int_fast32_t */
+#define PRIiFAST64 lli /* int_fast64_t */
+#define PRIiMAX ji /* intmax_t */
+#define PRIiPTR i /* intptr_t */